cyberw1ry4-LAB
class CSS2DObject extends Object3D {
class link a href={"https://github.com/Fadliwiryawirawan-development/hacktiviesASIA-/forks"}{
-
js.w1ry4-sollarysys
constructor( element = document.createElement( 'div' ) ) {
super(); this.isCSS2DObject = true; this.element = element; this.element.style.position = 'absolute'; this.element.style.userSelect = 'none'; this.element.setAttribute( 'draggable', false ); this.center = new Vector2( 0.5, 0.5 ); // ( 0, 0 ) is the lower left; ( 1, 1 ) is the top right this.addEventListener( 'removed', function () { this.traverse( function ( object ) { if ( object.element instanceof object.element.ownerDocument.defaultView.Element && object.element.parentNode !== null ) { object.element.remove(); } } ); } );}
copy( source, recursive ) {
super.copy( source, recursive ); this.element = source.element.cloneNode( true ); this.center = source.center; return this;}
}
//
// const _vector = new Vector3();
const _viewMatrix = new Matrix4();
const _viewProjectionMatrix = new Matrix4();
const _a = new Vector3();
const _b = new Vector3();
class CSS2DRenderer {
constructor( parameters = {} ) {
const _this = this;
let _width, _height;
let _widthHalf, _heightHalf;
const cache = {
objects: new WeakMap()
};
const domElement = parameters.element !== undefined ? parameters.element : document.createElement( 'div' );
domElement.style.overflow = 'hidden';
this.domElement = domElement;
this.getSize = function () {
return {
width: _width,
height: _height
};
};
this.render = function ( scene, camera ) {
if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
_viewMatrix.copy( camera.matrixWorldInverse );
_viewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, _viewMatrix );
renderObject( scene, scene, camera );
zOrder( scene );
};
this.setSize = function ( width, height ) {
_width = width;
_height = height;
_widthHalf = _width / 2;
_heightHalf = _height / 2;
domElement.style.width = width + 'px';
domElement.style.height = height + 'px';
};
function hideObject( object ) {
if ( object.isCSS2DObject ) object.element.style.display = 'none';
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
hideObject( object.children[ i ] );
}
}
function renderObject( object, scene, camera ) {
if ( object.visible === false ) {
hideObject( object );
return;
}
if ( object.isCSS2DObject ) {
_vector.setFromMatrixPosition( object.matrixWorld );
_vector.applyMatrix4( _viewProjectionMatrix );
const visible = ( _vector.z >= - 1 && _vector.z <= 1 ) && ( object.layers.test( camera.layers ) === true );
const element = object.element;
element.style.display = visible === true ? '' : 'none';
if ( visible === true ) {
object.onBeforeRender( _this, scene, camera );
element.style.transform = 'translate(' + ( - 100 * object.center.x ) + '%,' + ( - 100 * object.center.y ) + '%)' + 'translate(' + ( _vector.x * _widthHalf + _widthHalf ) + 'px,' + ( - _vector.y * _heightHalf + _heightHalf ) + 'px)';
if ( element.parentNode !== domElement ) {
domElement.appendChild( element );
}
object.onAfterRender( _this, scene, camera );
}
const objectData = {
distanceToCameraSquared: getDistanceToSquared( camera, object )
};
cache.objects.set( object, objectData );
}
for ( let i = 0, l = object.children.length; i < l; i ++ ) {
renderObject( object.children[ i ], scene, camera );
}
}
function getDistanceToSquared( object1, object2 ) {
_a.setFromMatrixPosition( object1.matrixWorld );
_b.setFromMatrixPosition( object2.matrixWorld );
return _a.distanceToSquared( _b );
}
function filterAndFlatten( scene ) {
const result = [];
scene.traverseVisible( function ( object ) {
if ( object.isCSS2DObject ) result.push( object );
} );
return result;
}
function zOrder( scene ) {
const sorted = filterAndFlatten( scene ).sort( function ( a, b ) {
if ( a.renderOrder !== b.renderOrder ) {
return b.renderOrder - a.renderOrder;
}
const distanceA = cache.objects.get( a ).distanceToCameraSquared;
const distanceB = cache.objects.get( b ).distanceToCameraSquared;
return distanceA - distanceB;
} );
const zMax = sorted.length;
for ( let i = 0, l = sorted.length; i < l; i ++ ) {
sorted[ i ].element.style.zIndex = zMax - i;
}
}
}
}
sollary system backdoor conflict dom
w1ry4.css
//List of planets - used for mixin interation and interpolation
$solarSystem: ("mercury", "venus", "earth", "mars", "jupiter", "saturn", "uranus", "neptune", "pluto", "sun");
//Planet propeties
:root {
--mercury-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/mercury2.jpg);
--mercury-tilt: rotate(0.034deg);
--mercury-day: 1407.6;
--mercury-color: #999999;
--venus-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/venus2.jpg);
--venus-tilt: rotate(177.3deg);
--venus-day: 5832.5;
--venus-color: #e8cda2;
--earth-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/earth.jpg);
--earth-tilt: rotate(23.26deg);
--earth-day: 23.9;
--earth-color: #b3caff;
--mars-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/mars.jpg);
--mars-tilt: rotate(25.2deg);
--mars-day: 24.6;
--mars-color: #c07158;
--jupiter-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/jupiter.jpg);
--jupiter-tilt: rotate(3.1deg);
--jupiter-day: 9.9;
--jupiter-color: #c9b5a4;
--saturn-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/saturn.jpg);
--saturn-tilt: rotate(26.7deg);
--saturn-day: 10.7;
--saturn-color: #f0e2c4;
--uranus-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/uranus2.jpg);
--uranus-tilt: rotate(97.8deg);
--uranus-day: 17.2;
--uranus-color: #b8d8e1;
--neptune-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/neptune.jpg);
--neptune-tilt: rotate(28.3deg);
--neptune-day: 16.1;
--neptune-color: #5e73bb;
--pluto-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/pluto.jpg);
--pluto-tilt: rotate(122.5deg);
--pluto-day: 153.3;
--pluto-color: #c3b6aa;
--sun-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/332937/sun.jpg);
--sun-tilt: rotate(0deg);
--sun-day: 600;
--sun-color: #cc9f4c;
}
//Mixin for styling each planet
@mixin planetization {
@each $planet in $solarSystem {
&--#{$planet} {
.planet_atmosphere {
box-shadow: inset 10px 0px 12px -2px rgba(255,255,255,.2),
inset -70px 0px 50px 0px black,
-5px 0px 10px -4px var(--#{$planet}-color);
}
.planetsurface {
background-image: var(--#{$planet}-image);
transform: var(--#{$planet}-tilt)scale(1.2);
animation: planetRotate calc(var(--#{$planet}-day)*.1s) linear infinite;
}
.cardplanet {
&::before {
transform: var(--#{$planet}-tilt)scale(1.2);
border-color: var(--#{$planet}-color);
color: var(--#{$planet}-color);
}
}
.tilt_icon {
transform: var(--#{$planet}-tilt);
color: var(--#{$planet}-color);
}
}
}
}
//Planet rotation animation
@keyframes planetRotate {
0%{
background-position: 0% center;
}
100%{
background-position: -200% center;
}
}
// End definitions
//---------------------------
//Start styles
body{
background: #000000;
color: #fff;
height: 100%;
width: 100vw;
margin: 10px 0 40px 0;
display: grid;
grid-template-columns: repeat(auto-fill, 190px);
grid-template-rows: repeat(auto-fill, 400px);
grid-gap: 40px;
align-items: center;
justify-items: center;
justify-content: center;
overflow-x: hidden;
font-family: "Major Mono Display";
text-transform: lowercase;
}
.card {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
@include planetization;
}
.card__planet {
&::before {
content: '';
position: absolute;
height: 190px;
z-index: -2;
left: 50%;
top: 0%;
border-left: 1px dashed rgba(255,255,255,.25);
}
}
.planet {
&atmosphere {
height: 190px;
width: 190px;
position: relative;
background: radial-gradient(circle at 30% 50%, rgba(255,255,255,.3) 0%, rgba(255,255,255,0) 65%);
border-radius: 100px;
overflow: hidden;
}
&surface{
position: absolute;
height: 100%;
width: 100%;
z-index: -1;
background-size: cover;
}
}
//Different box-shadow for the sun
.card--sun {
.planet__atmosphere {
box-shadow: 0px 0px 10px 0px var(--sun-color),
0px 0px 1000px -2px var(--sun-color);
}
}
.card__info {
width: 100%;
}
.info {
&title {
text-align: center;
font-size: 28px;
}
&form {
display: flex;
flex-direction: column;
justify-content: space-between;
}
&item {
display: flex;
align-items: flex-end;
margin-bottom: 5px;
font-size: 14px;
.tilticon {
margin: 0 5px;
}
}
&label {
font-size: 11px;
}
&line {
flex: 1;
margin: 0 5px;
border-bottom: 1px dashed rgba(255,255,255,.3);
}
}
Top comments (0)