Skip to content

Instantly share code, notes, and snippets.

@dvtate
Created September 9, 2020 00:11
Show Gist options
  • Save dvtate/adca6ff625feb23cee8a9cd8c2de4c41 to your computer and use it in GitHub Desktop.
Save dvtate/adca6ff625feb23cee8a9cd8c2de4c41 to your computer and use it in GitHub Desktop.
lmao
const { expect } = require('chai');
const { Vector3 } = require('three');
describe('lookup', function callback() {
it('does not crash', function callback() {
const jsdom = new (require('jsdom')).JSDOM();
const canvas = jsdom.window.document.createElement('canvas');
global.window = jsdom.window;
global.document = jsdom.window.document;
const THREE = require('three');
const width = 400, height = 200;
const context = require('gl')(200, 400);
const renderer = new THREE.WebGLRenderer({
antialias: true,
canvas, context
});
renderer.sortObjects = false;
renderer.setClearColor(0xffffff);
renderer.setSize(width, height, false);
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
camera.position.z = 1;
scene = new THREE.Scene();
geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
material = new THREE.MeshNormalMaterial();
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
const points = [
new Vector3(1,3,4),
new Vector3(3,5,7),
new Vector3(9,4,3),
new Vector3(1,3,2),
];
const line = new THREE.Line(new THREE.BufferGeometry().setFromPoints(points), new THREE.LineBasicMaterial({ color: 0x666fff }));
scene.add(line);
const wf = new THREE.LineSegments(new THREE.WireframeGeometry(new THREE.SphereBufferGeometry( 100, 100, 100 )));
scene.add(wf);
renderer.setSize( window.innerWidth, window.innerHeight );
window.document.body.appendChild( renderer.domElement );
renderer.render(scene, camera);
let recursive = {};
recursive.r = recursive;
recursive.obj = { m : {}, r : recursive};
recursive.obj.m.r = recursive.obj;
recursive.toJSON = function () {
return this;
};
expect(scene.children).to.include.members([wf, recursive, mesh]);
wf.removeFromScene();
expect(scene.children).to.include(wf);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment