Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="css3d" id="css3d">
  <div class="youtube-wrapper">
    <div class="iframe-wrapper">
    <iframe width="560" height="315" src="https://www.youtube.com/embed/KAvafLZZ7J0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
  </div>
  </div>
</div>

<p class="credit">
  This work uses a model created under the CC-BY-4.0 license. Original author: AnnPiskacov (https://sketchfab.com/AndreaPiskacova)
</p>

    <nav class="action-nav">
      <button class="button" id="zoom-button">画面に近づく</button>
      <button class="button" id="pull-button">元の位置に戻る</button>
    </nav>

<script async src="https://ga.jspm.io/npm:es-module-shims@1.5.1/dist/es-module-shims.js" crossorigin="anonymous"></script>
<script type="importmap">
  {
    "imports": {
      "three": "https://unpkg.com/three@0.152.0/build/three.module.js",
      "three/addons/": "https://unpkg.com/three@0.152.0/examples/jsm/"
    }
  }
</script>

              
            
!

CSS

              
                body {
  color: #333;
  position: relative;
  width: 100vw;
  overflow: hidden;
}

p {
  margin: 0;
  padding: 0;
  line-height: 1.2;
}

iframe {
  overflow: auto;
}

.css3d {
  -webkit-perspective: 1000px;
  perspective: 1000px;
  opacity: 0
}
.iframe-wrapper {
  /* width: 1260px; */
  aspect-ratio: 16 / 9;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;
  /* transform: scale(0.44); */
}

.iframe-wrapper iframe {
  /* width: 100%;
  height: 100%; */
}

.credit {
  position: absolute;
  bottom: 16px;
  left: 16px;
  color: #fff;
  font-size: 10px;
}
.action-nav {
  position: fixed;
  left: 24px;
  top: 24px;
  z-index: 100000;
}
.button {
  background-color: #eee;
  z-index: 10000;
  font-size: 18px;
  padding: 0.5em 2em;
  border-radius: 40px;
  color: #fff;
}
.button:hover {
  opacity: 0.8;
}
#zoom-button {
  background-color: #c24242;
}
#pull-button {
  background-color: #425cc2;
}

@media screen and (max-width: 767px) {
  .button {
    display: block;
    font-size: 11px;
  }
  #pull-button {
    margin-top: 16px;
  }
}

              
            
!

JS

              
                import * as THREE from "three";
import { CSS3DRenderer, CSS3DObject } from 'three/addons/renderers/CSS3DRenderer.js';
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";

let camera, scene, renderer,scene2, cssrenderer,object,wsw,css3dobject;
let cameraPosition = new THREE.Vector3(1000, 500, 700);
let cameraPositionSp = new THREE.Vector3(1000, 500, 800);
let cameraTargetPosition = new THREE.Vector3(400, 600, -20);
let cameraTargetPositionSp = new THREE.Vector3(700, 600, 40);

init();
animate();

function init() {
	camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1.0, 4000);
	wsw = window.screen.width;
	if (wsw < 768) {
		camera.position.set(cameraPositionSp.x, cameraPositionSp.y, cameraPositionSp.z);
		camera.fov=60
	}
	else{
		camera.position.set(cameraPosition.x, cameraPosition.y, cameraPosition.z);
	}
	camera.rotation.set(0, THREE.MathUtils.degToRad(60), 0);

	scene = new THREE.Scene();
	scene.background = new THREE.Color(0xffffff);
	const light = new THREE.SpotLight(0xFFFFFF, 4, 2200, Math.PI / 4, 1, 0.5);
	light.position.set(0, 2200, 0);
	scene.add(light);

	scene2 = new THREE.Scene();

	const loader = new GLTFLoader();
	loader.load('https://anbitbeans.github.io/css3d//isometric_room/scene.gltf', (data) => {
		const gltf = data;
		object = gltf.scene;
		object.scale.set(620.0, 620, 620.0);
		object.position.set(0, 0, 0);
		object.rotation.y = THREE.MathUtils.degToRad(80); 
		scene.add(object);
	});

	const cssobj = document.getElementById("css3d");
	css3dobject = new CSS3DObject(cssobj);
	css3dobject.scale.set(1.04, 1.04, 1.0);
	css3dobject.position.set(-450, 603, -173);
	css3dobject.rotation.set(0, THREE.MathUtils.degToRad(80), 0);
	scene2.add(css3dobject);
    cssobj.style.opacity = '1';
  
	renderer = new THREE.WebGLRenderer();
	renderer.antialias = true;
	renderer.setPixelRatio((Math.min(window.devicePixelRatio, 2)));
	
	renderer.setSize(window.innerWidth, window.innerHeight);
	document.body.appendChild(renderer.domElement);

	cssrenderer = new CSS3DRenderer();
	cssrenderer.setSize(window.innerWidth, window.innerHeight);
	cssrenderer.domElement.style.position = 'absolute';
	cssrenderer.domElement.style.top = 0;
	document.body.appendChild(cssrenderer.domElement);

	window.addEventListener("DOMContentLoaded", onWindowResize);
	window.addEventListener("resize", onWindowResize);
	window.addEventListener("orientationchange", onWindowResize);

	document.getElementById("zoom-button").addEventListener("click", moveCamera);
	document.getElementById("pull-button").addEventListener("click", pullCamera);
}

function onWindowResize() {
    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();

    renderer.setSize(window.innerWidth, window.innerHeight);
    cssrenderer.setSize(window.innerWidth, window.innerHeight);
}

function animate() {
	requestAnimationFrame(animate);
	renderer.render(scene, camera);
	cssrenderer.render(scene2, camera);
}

function moveCamera() {
	const tl = gsap.timeline();
	wsw = window.screen.width;
	if (wsw < 768) {
		tl
		.to(camera.rotation, { duration: 3.0, y: THREE.MathUtils.degToRad(80) })
		.to(camera.position, { duration: 3.0, x: cameraTargetPositionSp.x, y: cameraTargetPositionSp.y,z: cameraTargetPositionSp.z,ease: "power4.out" }, "-=3.0");
	}
	else{
		tl
		.to(camera.rotation, { duration: 3.0, y: THREE.MathUtils.degToRad(80) })
		.to(camera.position, { duration: 3.0, x: cameraTargetPosition.x, y: cameraTargetPosition.y,z: cameraTargetPosition.z,ease: "power4.out"}, "-=3.0");
	}

 }

 function pullCamera() {
	const tl = gsap.timeline();

	wsw = window.screen.width;
	if (wsw < 768) {
		tl
		.to(camera.rotation, { duration: 3.0, y: THREE.MathUtils.degToRad(60),ease: "power4.out"})
		.to(camera.position, { duration: 3.0, x: cameraPositionSp.x, y: cameraPositionSp.y,z: cameraPositionSp.z,ease: "power4.out" }, "-=3.0");
	}
	else{
		tl
		.to(camera.rotation, { duration: 3.0, y: THREE.MathUtils.degToRad(60),ease: "power4.out"})
		.to(camera.position, { duration: 3.0, x: cameraPosition.x, y: cameraPosition.y,z: cameraPosition.z,ease: "power4.out" }, "-=3.0");
	}

 }
              
            
!
999px

Console