How to use the Math function from three
Find comprehensive JavaScript three.Math code examples handpicked from public code repositorys.
35 36 37 38 39 40 41 42 43 44
var CanvasRenderer = function ( parameters ) { console.log( 'CanvasRenderer', THREE.REVISION ); var smoothstep = THREE.Math.smoothstep; parameters = parameters || {}; var _this = this,
185
870
40
+ 9 other calls in file
GitHub: MozillaReality/puzzle-rain
57 58 59 60 61 62 63 64 65
Dot.prototype = Object.create(THREE.Object3D.prototype); Dot.prototype.update = function (delta, time) { this.ring.quaternion.copy(this.camera.quaternion); if (!this.isPlaced) { var scaleVolume = THREE.Math.mapLinear(this.creature.track.averageAnalyser * Math.min(1, this.creature.track.getVolume()), 0, 100, 1.5, 3); this.ring.scale.set(scaleVolume, scaleVolume, scaleVolume); } };
10
33
10
136 137 138 139 140 141 142 143 144 145
if(!camera.parent) camera.updateMatrixWorld(); camera.matrixWorld.decompose(_position, _quaternion, _scale); // Effective fov of the camera _fov = THREE.Math.radToDeg(2 * Math.atan(Math.tan(THREE.Math.degToRad(camera.fov) * 0.5) / camera.zoom)); _ndfl = camera.near / this.focalLength; _halfFocalHeight = Math.tan(THREE.Math.degToRad(_fov) * 0.5) * this.focalLength; _halfFocalWidth = _halfFocalHeight * 0.5 * camera.aspect;
2
4
2
GitHub: jamesarnall/storyboarder
62 63 64 65 66 67 68 69 70 71
// round to nearest step value const steps = (value, step) => parseFloat((Math.round(value * (1 / step)) * step).toFixed(6)) const lensFactory = (min, max, step = 0.05) => R.lens( from => THREE.Math.mapLinear(from, min, max, 0, 1), to => { let value = mapLinear(to, 0, 1, min, max) value = steps(value, step) value = clamp(value, min, max)
263
0
1
14 15 16 17 18 19 20 21 22 23
// this.params.tPerturb = null; this.params.mode = options.mode || 0; this.counter = 0; this.breakPoint = 0; this.breakPoint = THREE.Math.randInt(120, 240); if(options.perturbMap !== undefined) { this.params.tPerturb = options.perturbMap;
37
135
0
+ 25 other calls in file
96 97 98 99 100 101 102 103 104 105
this.screenOrientation = orientation; this.autoAlign = true; } this.alpha = this.deviceOrientation.gamma ? THREE.Math.degToRad(this.deviceOrientation.alpha) : 0; // Z this.beta = this.deviceOrientation.beta ? THREE.Math.degToRad(this.deviceOrientation.beta) : 0; // X' this.gamma = this.deviceOrientation.gamma ? THREE.Math.degToRad(this.deviceOrientation.gamma) : 0; // Y''
6
30
7
+ 7 other calls in file
195 196 197 198 199 200 201 202 203
} if ( this.heightSpeed ) { var y = THREE.Math.clamp( this.object.position.y, this.heightMin, this.heightMax ); var heightDelta = y - this.heightMin; this.autoSpeedFactor = delta * ( heightDelta * this.heightCoef );
5
10
9
108 109 110 111 112 113 114 115 116 117
if ( device ) { var alpha = device.alpha ? THREE.Math.degToRad( device.alpha ) + scope.alphaOffset : 0; // Z var beta = device.beta ? THREE.Math.degToRad( device.beta ) : 0; // X' var gamma = device.gamma ? THREE.Math.degToRad( device.gamma ) : 0; // Y'' var orient = scope.screenOrientation ? THREE.Math.degToRad( scope.screenOrientation ) : 0; // O
4
9
5
+ 7 other calls in file
2464 2465 2466 2467 2468 2469 2470 2471 2472 2473
return; } if (cameraDef.type === "perspective") { camera = new THREE.PerspectiveCamera( THREE.Math.radToDeg(params.yfov), params.aspectRatio || 1, params.znear || 1, params.zfar || 2e6 );
3
7
8
+ 14 other calls in file
98 99 100 101 102 103 104 105 106 107
var textures = {}; // var json = { uuid: THREE.Math.generateUUID(), type: 'MeshLambertMaterial' }; for ( var name in m ) {
3
7
8
+ 7 other calls in file
GitHub: alimalkhalifa/VisualEQ
58 59 60 61 62 63 64 65 66 67
fragment.scaleX, fragment.scaleX, fragment.scaleY, ], rot: [ THREE.Math.degToRad(fragment.rotX / (512/360)), THREE.Math.degToRad(fragment.rotY / (512/360)), THREE.Math.degToRad(fragment.rotZ / (512/360)) ] })
0
3
0
+ 5 other calls in file
GitHub: eic/root2cad
230 231 232 233 234 235 236 237 238 239
* @returns {Boolean} Returns true if image size is POT. * */ function isPowerOfTwo( image ) { return THREE.Math.isPowerOfTwo( image.width ) && THREE.Math.isPowerOfTwo( image.height ); } /**
0
2
0
+ 7 other calls in file
385 386 387 388 389 390 391 392 393 394
camera.projectionMatrix.makeFrustum( left, right, bottom, top, camera.near, camera.far); // Recalculate the fov as threejs is not doing it. camera.fov = THREE.Math.radToDeg( Math.atan((top * camera.zoom) / camera.near)) * 2.0; } } else {
0
2
0
GitHub: star8ks/sketch
60 61 62 63 64 65 66 67 68 69
}); } setPressure(val) { let valid = val <= this.opt.pressureMax && val >= 0.0; this.pressure = THREE.Math.clamp(val, 0.0, this.opt.pressureMax); // console.log(this.pressure); return valid; } onDown(e) {
1
1
1
+ 107 other calls in file
GitHub: VeinKowal/veins
592 593 594 595 596 597 598 599 600 601
camera.updateProjectionMatrix(); // setup camera placement cameraTransformOptions.range = 1000; } else if (camera.isPerspectiveCamera) { // setup range for camera placement var verticalFOV = THREE.Math.degToRad(camera.fov); if (dimensions.x / dimensions.y > camera.aspect) { var focal = view.domElement.clientHeight * 0.5 / Math.tan(verticalFOV * 0.5); var horizontalFOV = 2 * Math.atan(view.domElement.clientWidth * 0.5 / focal);
0
1
1
+ 10 other calls in file
732 733 734 735 736 737 738 739 740
// For now just assume one model and get the preRotations from that var modelNode = modelNodes[ 0 ]; if ( 'GeometricRotation' in modelNode.properties ) { var array = modelNode.properties.GeometricRotation.value.map( THREE.Math.degToRad ); array[ 3 ] = 'ZYX'; preTransform.makeRotationFromEuler( new THREE.Euler().fromArray( array ) );
0
0
1
+ 800 other calls in file
2605 2606 2607 2608 2609 2610 2611 2612 2613 2614
default: this.obj.x = data[ 0 ]; this.obj.y = data[ 1 ]; this.obj.z = data[ 2 ]; this.angle = THREE.Math.degToRad( data[ 3 ] ); break; } break;
0
0
2
+ 43 other calls in file
1256 1257 1258 1259 1260 1261 1262 1263 1264 1265
this.update = function () { if (scope.enabled === false) return; var device = scope.deviceOrientation; if (device) { var alpha = device.alpha ? THREE.Math.degToRad(device.alpha) + scope.alphaOffset : 0; // Z var beta = device.beta ? THREE.Math.degToRad(device.beta) : 0; // X' var gamma = device.gamma ? THREE.Math.degToRad(device.gamma) : 0; // Y''
0
0
0
+ 7 other calls in file
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267
var device = scope.deviceOrientation; if (device) { var alpha = device.alpha ? THREE.Math.degToRad(device.alpha) + scope.alphaOffset : 0; // Z var beta = device.beta ? THREE.Math.degToRad(device.beta) : 0; // X' var gamma = device.gamma ? THREE.Math.degToRad(device.gamma) : 0; // Y'' var orient = scope.screenOrientation ? THREE.Math.degToRad(scope.screenOrientation) : 0; // O
0
0
0
+ 7 other calls in file
347 348 349 350 351 352 353 354 355 356
var h = document.documentElement.clientHeight; // Display result inside a div element // console.log("Width: " + w + ", " + "Height: " + h); renderer.setSize(w, h); // camera.fov = Math.atan(window.innerHeight / 2 / camera.position.z) * 2 * THREE.Math.RAD2DEG; camera.aspect = w / h; camera.updateProjectionMatrix(); }
0
0
0
+ 6 other calls in file
three.Vector3 is the most popular function in three (22341 examples)