Published
Edited
Mar 6, 2022
2 forks
Insert cell
Insert cell
loaderGLTF = new THREE.GLTFLoader()
Insert cell
Insert cell
Insert cell
Insert cell
{
loaderGLTF.load(
boatPath,
(gltf) => {
var shipGLTF = gltf.scene;
shipGLTF.rotation.x = Math.PI / 2;
shipGLTF.rotation.y = -Math.PI / 2;
shipGLTF.position.set(-1, 0, 0);
shipGLTF.name = "ModelGLTF";

if (shipGLTF.material) {
shipGLTF.material.side = THREE.DoubleSide;
}

scene.add(shipGLTF);
},
(xhr) => {
mutable loaderPecentage = (xhr.loaded / 31780028) * 100;
}
);
}
Insert cell
Insert cell
Insert cell
{
const renderer = new THREE.WebGLRenderer({antialias: true});
renderer.toneMapping = THREE.ReinhardToneMapping;
renderer.toneMappingExposure = 2.3;
scene.background = new THREE.Color(0xA9CCE3);
const height = 600;
const aspect = width / height;
const camera = new THREE.PerspectiveCamera(50, aspect);
camera.up.set(0, 0, 1);
scene.add(camera);
camera.position.set(30, 20, 20);
function onWindowResize() {
renderer.setSize(width, height);
camera.aspect = width / height;
camera.updateProjectionMatrix();
}
window.addEventListener('resize', onWindowResize);

const controls = new THREE.OrbitControls(camera, renderer.domElement);
controls.target = new THREE.Vector3(0, 0, 0);
controls.update();
invalidation.then(() => renderer.dispose());
renderer.setSize(width, height);
renderer.setPixelRatio(devicePixelRatio);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.3);
const mainLight = new THREE.DirectionalLight(0xffffff, 1);
mainLight.position.set(1, 1, 1);
scene.add(ambientLight, mainLight);
var animate = function () {
requestAnimationFrame( animate );
renderer.render( scene, camera );
};
animate();
yield renderer.domElement;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more