/* globals AMI*/
// VJS classes we will be using in this lesson
var LoadersVolume = AMI.default.Loaders.Volume;
var ControlsTrackball = AMI.default.Controls.Trackball;
var HelpersStack = AMI.default.Helpers.Stack;
// Setup renderer
var container = document.getElementById('container');
var renderer = new THREE.WebGLRenderer({
antialias: true,
logarithmicDepthBuffer: false,
});
renderer.setSize(container.offsetWidth, container.offsetHeight);
renderer.setClearColor(0x353535, 1);
renderer.setPixelRatio(window.devicePixelRatio);
// configuration to work with clip CAP
renderer.autoClear=false;
renderer.localClippingEnabled = true;
container.appendChild(renderer.domElement);
// Setup scene
var scene = new THREE.Scene();
// Setup clip scene
var sceneClip = new THREE.Scene();
var clipPlane = new THREE.Plane(new THREE.Vector3(0, 0, 0), 0); // The plane to do clip!
// Setup camera
var camera = new THREE.PerspectiveCamera(
45, container.offsetWidth / container.offsetHeight, 0.1, 1000000);
camera.position.x = 150;
camera.position.y = 150;
camera.position.z = 100;
// Setup controls
var controls = new ControlsTrackball(camera, container);
/**
* Handle window resize
*/
function onWindowResize() {
camera.aspect = container.offsetWidth / container.offsetHeight;
camera.updateProjectionMatrix();
renderer.setSize(container.offsetWidth, container.offsetHeight);
}
window.addEventListener('resize', onWindowResize, false);
// Setup lights
var particleLight = new THREE.Mesh(
new THREE.SphereBufferGeometry(4, 8, 8),
new THREE.MeshBasicMaterial({color: 0xffffff}));
scene.add(particleLight);
scene.add(new THREE.AmbientLight(0x222222));
var directionalLight = new THREE.DirectionalLight(0xffffff, 1);
directionalLight.position.set(1, 1, 1).normalize();
scene.add(directionalLight);
var pointLight = new THREE.PointLight(0xffffff, 2, 800);
particleLight.add(pointLight);
// Load STL model
var loaderSTL = new...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.