JSFiddle - React, Tailwind, and code Playground
by realhunts
HTML
<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
<script src="//cdn.rawgit.com/mrdoob/three.js/master/examples/js/loaders/GLTFLoader.js"></script>
<script src="https://stemkoski.github.io/Three.js/js/Stats.js"></script>
<script src="https://mevedia.com/share/StaticMesh.js?z96"></script>
JavaScript
// a basic three.js scene
var container, renderer, scene, camera, controls;
var stats, mixer;
init();
animate();
function init() {
// renderer
renderer = new THREE.WebGLRenderer({
antialias: false
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setClearColor(0xccccff);
container = document.createElement('div');
document.body.appendChild(container);
container.appendChild(renderer.domElement);
renderer.setPixelRatio(.7)
// scene
scene = new THREE.Scene();
scene.background = new THREE.Color( "gray" );
scene.fog = new THREE.Fog( "gray", 100, 400 );
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
stats.domElement.style.zIndex = 100;
container.appendChild( stats.domElement );
// camera
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.set(0, 200, 800);
camera.lookAt(scene.position);
// (camera) controls
// mouse controls: left button to rotate,
// mouse wheel to zoom, right button to pan
controls = new THREE.OrbitControls(camera, renderer.domElement);
// light
var light = new THREE.PointLight(0xffffff);
light.position.set(100, 250, 250);
scene.add(light);
// imported
var loader = new THREE.GLTFLoader();
var scale = 2.;
loader.load('https://cdn.glitch.com/46bf3e57-ee80-42c3-98fd-29842963a871%2Fscene.glb?v=1569088198904', (data) => {
data.scene.traverse((child) => {
if (child instanceof THREE.Mesh) {
//console.log(child.material)
if (child.material.type = "MeshStandardMaterial") {
child.material.dispose();
scene.remove(child.material)
child.material = new THREE.MeshLambertMaterial({
color: child.material.color.multiplyScalar(10.0),
...