xxxxxxxxxx
105
/*
Real Time Social Spaces: This is an example of a basic three.js scene (in the p5.js editor). It shows the following parts of the scene
Storing everything in a scene:
THREE.Scene()
Adding a camera:
THREE.PerspectiveCamera()
Setting up a renderer:
THREE.WebGLRenderer()
Finally, it adds a sphere to the scene:
THREE.SphereGeometry()
THREE.MeshBasicMaterial()
THREE.Mesh()
Next, we'll explore some more aspects of three.js scenes:
Change renderer size (i.e. canvas size)
Changing geometries
Changing materials
Adding lights
Add a render loop
Changing the renderer's 'clear color'
*/
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, 1, 0.1, 1000);
camera.position.z = 5;
var renderer = new THREE.WebGLRenderer();
renderer.setSize(800, 800);
document.body.appendChild(renderer.domElement);
// var geometry = new THREE.SphereGeometry(1, 12, 12);
// var material = new THREE.MeshPhongMaterial({color: 0xff2233});
// var cube = new THREE.Mesh(geometry, material);
// scene.add(cube);
// add a light:
let light = new THREE.AmbientLight(0xffffff);
light.intensity = 1;
scene.add(light)
// let dl = new THREE.DirectionalLight(0xff33ff);
// scene.add(dl);
let mm;
// Instantiate a loader
const loader = new THREE.GLTFLoader();
// Optional: Provide a DRACOLoader instance to decode compressed mesh data
// const dracoLoader = new DRACOLoader();
// dracoLoader.setDecoderPath( '/examples/js/libs/draco/' );
// loader.setDRACOLoader( dracoLoader );
// Load a glTF resource
loader.load(
// resource URL
'https://assets.vlts.pw/spaceAssets/aidan/2-uv-sets.glb',
// called when the resource is loaded
function ( gltf ) {
scene.add( gltf.scene );
mm= gltf.scene;
gltf.animations; // Array<THREE.AnimationClip>
gltf.scene; // THREE.Group
gltf.scenes; // Array<THREE.Group>
gltf.cameras; // Array<THREE.Camera>
gltf.asset; // Object
renderer.render(scene, camera);
},
// called while loading is progressing
function ( xhr ) {
console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' );
},
// called when loading has errors
function ( error ) {
console.log( 'An error happened' );
}
);
renderer.render(scene, camera);