How to use the Object3D function from three
Find comprehensive JavaScript three.Object3D code examples handpicked from public code repositorys.
GitHub: edankwan/The-Spirit
23 24 25 26 27 28 29 30 31 32
var TEXTURE_HEIGHT = settings.simulatorTextureHeight; var AMOUNT = TEXTURE_WIDTH * TEXTURE_HEIGHT; function init(renderer) { container = exports.container = new THREE.Object3D(); _tmpColor = new THREE.Color(); _color1 = new THREE.Color(settings.color1); _color2 = new THREE.Color(settings.color2);
160
993
36
25 26 27 28 29 30 31 32 33 34
* @requires jQuery, THREE, TweenLite, random, noise, map */ function FlowField (points, options) { this.parameters = jQuery.extend(FlowField.defaultOptions, options); var group = new THREE.Object3D(); var curves = this.getCurves(points); var main = curves.main; var subs = curves.subs;
57
254
10
+ 7 other calls in file
92 93 94 95 96 97 98 99 100 101
if (this.parameters.points) { group.add(pointCloud); } // lines var lines = new THREE.Object3D(); var lineMaterial = new THREE.LineBasicMaterial({ color: this.parameters.linesColor, vertexColors: THREE.VertexColors
57
254
10
+ 5 other calls in file
30 31 32 33 34 35 36 37 38
var curCamZoom = 60; var curCamHeight = 70; var cameraReferenceOrientation = new THREE.Quaternion(); var cameraReferenceOrientationObj = new THREE.Object3D(); var poleDir = new THREE.Vector3(1,0,0); this.update = function() {
15
47
10
+ 3 other calls in file
175 176 177 178 179 180 181 182 183 184
const dist = direction.length(); const length = dist; const geometry = new Tube(start, end, thickness, thickness, length, radiusSegments, lengthSegments, openEnded); geometry.translate(0, length / 2, 0); const object = new THREE.Object3D(); object.position.copy(start); quatFromDir(direction.clone().normalize(), object.quaternion); if (matrix) object.applyMatrix(matrix); object.updateMatrix();
3
39
2
+ 15 other calls in file
GitHub: ASSERT-KTH/ci-hackathon
250 251 252 253 254 255 256 257 258 259
spotLight.shadow.camera.near = 500; spotLight.shadow.camera.far = 4000; spotLight.shadow.camera.fov = 30; var targetObject = new THREE.Object3D(); targetObject.position.set( position[0], position[1] + 10, position[2] - 3)
26
28
0
+ 2 other calls in file
GitHub: VCityTeam/UD-Viz
25 26 27 28 29 30 31 32 33 34
*/ constructor(json) { super(); /** * tag to make difference between this and THREE.Object3D * * @type {boolean} */ this.isGameObject3D = true;
16
12
9
19 20 21 22 23 24 25 26 27 28 29 30 31 32
var vrDisplay; var movementOnPress = 0.01; function Gamepad (hand) { THREE.Object3D.call(this); vrDisplay = State.get('vrDisplay'); this.gamepadVive;
10
33
0
547 548 549 550 551 552 553 554 555 556
}; } createNeuron(swcJSON, color = undefined) { // neuron is object 3d which ensures all components move together const neuron = new THREE.Object3D(); let geometry; let material; // particle mode uses vertex info to place texture image, very fast if (this.mode === "particle") {
7
21
7
+ 3 other calls in file
4 5 6 7 8 9 10 11 12 13
* @author arodic / https://github.com/arodic */ const TransformControls = function ( camera, domElement ) { THREE.Object3D.call( this ); domElement = ( domElement !== undefined ) ? domElement : document; this.visible = false;
4
26
11
+ 11 other calls in file
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624
}; }; TransformControls.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), { constructor: TransformControls, isTransformControls: true
4
26
0
+ 7 other calls in file
2768 2769 2770 2771 2772 2773 2774 2775 2776 2777
} else if (objects.length > 1) { node = new THREE.Group(); } else if (objects.length === 1) { node = objects[0]; } else { node = new THREE.Object3D(); } if (node !== objects[0]) { for (var i = 0, il = objects.length; i < il; i++) {
3
7
8
+ 14 other calls in file
GitHub: audunsh/evince
470 471 472 473 474 475 476 477 478
let m4_rot = new THREE.Matrix4(); let m4_trans = new THREE.Matrix4(); let m4_scale = new THREE.Matrix4(); let dummy = new THREE.Object3D(); let quaternion = new THREE.Quaternion();
3
7
0
+ 2 other calls in file
2268 2269 2270 2271 2272 2273 2274 2275 2276 2277
_markDefs() { const nodeDefs = this.json.nodes || []; const skinDefs = this.json.skins || []; const meshDefs = this.json.meshes || []; // Nothing in the node definition indicates whether it is a THREE.Bone or an // THREE.Object3D. Use the skins' joint references to mark bones. for ( let skinIndex = 0, skinLength = skinDefs.length; skinIndex < skinLength; skinIndex ++ ) { const joints = skinDefs[ skinIndex ].joints;
2
10
0
+ 3 other calls in file
2317 2318 2319 2320 2321 2322 2323 2324 2325 2326
} else if (objects.length === 1) { node = objects[0]; } else { node = new three.Object3D(); } if (node !== objects[0]) { for (let i = 0, il = objects.length; i < il; i++) { node.add(objects[i]);
2
7
0
18 19 20 21 22 23 24 25 26 27
// edgeLengthRatio = edgeLengthRatio !== undefined ? edgeLengthRatio : 0.7 ; var pointMid = new THREE.Vector3().addVectors(pointX, edgeLengthRatio * direction); var orientation = new THREE.Matrix4(); orientation.lookAt(pointX, pointY, new THREE.Object3D().up); orientation.multiply(new THREE.Matrix4().set(1, 0, 0, 0, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1));
4
6
3
39 40 41 42 43 44 45 46 47 48
this.curView = this.views.all; this.diagram = { form: { objects: { root: new THREE.Object3D(), vertices: new THREE.Object3D(), edges: new THREE.Object3D(), exEdges: new THREE.Object3D(),
4
6
3
+ 19 other calls in file
37 38 39 40 41 42 43 44 45 46
// VR INIT // Apply VR headset positional data to camera. orbitcontrols = new keycontrols.VRKeyControls(camera); // Store the position of the VR HMD in a dummy camera to allow for panning and junk fakeCamera = new three.Object3D(); vrControls = new three.VRControls(fakeCamera); // Apply VR stereo rendering to renderer. effect = new three.VREffect(renderer); effect.setSize(window.innerWidth, window.innerHeight);
1
3
5
+ 9 other calls in file
7 8 9 10 11 12 13 14 15 16
module.exports = PointerLockControls = function (camera) { let scope = this camera.rotation.set(0, 0, 0) let pitchObject = new THREE.Object3D() pitchObject.name = 'pitchObject' pitchObject.add(camera) let yawObject = new THREE.Object3D()
398
1
1
+ 7 other calls in file
GitHub: ASLS-org/studio
836 837 838 839 840 841 842 843 844 845
* Prepare new moving head instance * * @private */ prepareInstance() { this._dummy = new THREE.Object3D(); this._headDummy = new THREE.Object3D(); this._yokeDummy = new THREE.Object3D(); this._beamDummy = new THREE.Object3D(); this._targetDummy = new THREE.Object3D();
0
7
0
+ 23 other calls in file
three.Vector3 is the most popular function in three (22341 examples)