clone() { let state = { ...this }; state.status = this.status; state.buffer = Buffer.from(state.buffer); delete state.clone; return state; }
// Project vector onto sphere's surface function prepare( vector ) { var vertex = vector.normalize().clone(); vertex.index = that.vertices.push( vertex ) - 1; // Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle. var u = azimuth( vector ) / 2 / Math.PI + 0.5; var v = inclination( vector ) / Math.PI + 0.5; vertex.uv = new THREE.Vector2( u, 1 - v ); return vertex; }
// Approximate a curved face with recursively sub-divided triangles. function make( v1, v2, v3 ) { var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] ); face.centroid.add( v1 ).add( v2 ).add( v3 ).divideScalar( 3 ); that.faces.push( face ); var azi = azimuth( face.centroid ); that.faceVertexUvs[ 0 ].push( [ correctUV( v1.uv, v1, azi ), correctUV( v2.uv, v2, azi ), correctUV( v3.uv, v3, azi ) ] ); }
test('should handle dates', t => { const smartClone = new SmartClone(); const date = new Date('1/1/2001'); t.is(smartClone.isCloning, false); smartClone.start(date.valueOf()); t.is(smartClone.isCloning, true); t.is(date.valueOf(), smartClone.clone); smartClone.done(); t.is(smartClone.isCloning, false); });
async keypress(input, event = {}) { this.keypressed = true; let key = keypress.action(input, keypress(input, event), this.options.actions); this.state.keypress = key; this.emit('keypress', input, key); this.emit('state', this.state.clone()); let fn = this.options[key.action] || this[key.action] || this.dispatch; if (typeof fn === 'function') { return await fn.call(this, input, key); } this.alert(); }
compare(targetValues) { const { deltas, errors } = this; this.errors = this.compareKernel(targetValues[0], deltas); this.deltas = clone(this.errors); release(deltas); release(errors); const inputLayerDeltas = this.inputLayer.deltas; this.inputLayer.deltas = clone(this.deltas); release(inputLayerDeltas); }
// Texture fixing helper. Spheres have some odd behaviours. function correctUV( uv, vector, azimuth ) { if ( ( azimuth < 0 ) && ( uv.x === 1 ) ) uv = new THREE.Vector2( uv.x - 1, uv.y ); if ( ( vector.x === 0 ) && ( vector.z === 0 ) ) uv = new THREE.Vector2( azimuth / 2 / Math.PI + 0.5, uv.y ); return uv.clone(); }
const createEntry = (li: Element, depth: number, isSelected: boolean): Option<Entry> => { return Traverse.parent(li).filter(Node.isElement).map((list) => { return { depth, isSelected, content: cloneItemContent(li), itemAttributes: Attr.clone(li), listAttributes: Attr.clone(list), listType: Node.name(list) as ListType }; }); }
function setMaterialShaders( material, shaders ) { material.uniforms = THREE.UniformsUtils.clone( shaders.uniforms ); material.vertexShader = shaders.vertexShader; material.fragmentShader = shaders.fragmentShader; }
var Quadtree2Quadrant = function Quadtree2Quadrant(leftTop, size, id, parent) { this.leftTop_ = leftTop.clone(); this.children_ = []; this.objects_ = {}; this.objectCount_ = 0; this.id_ = id || 0; this.parent_ = parent; this.refactoring_ = false; this.setSize(size); }
compare(targetValues) { // this is where weights attach to deltas // deltas will be zero on learn, so save it in error for comparing to mse later release(this.deltas); release(this.errors); release(this.inputLayer.deltas); this.deltas = this.compareKernel(this.weights, targetValues); this.inputLayer.deltas = clone(this.deltas); this.errors = clone(this.deltas); }
serialize() { return { loadResponse: clone(this.loadResponse) }; }
// Project vector onto sphere's surface function prepare( vector ) { var vertex = vector.normalize().clone(); vertex.index = that.vertices.push( vertex ) - 1; // Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle. var u = azimuth( vector ) / 2 / Math.PI + 0.5; var v = inclination( vector ) / Math.PI + 0.5; vertex.uv = new THREE.Vector2( u, 1 - v ); return vertex; }
// Approximate a curved face with recursively sub-divided triangles. function make( v1, v2, v3 ) { var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] ); face.centroid.add( v1 ).add( v2 ).add( v3 ).divideScalar( 3 ); that.faces.push( face ); var azi = azimuth( face.centroid ); that.faceVertexUvs[ 0 ].push( [ correctUV( v1.uv, v1, azi ), correctUV( v2.uv, v2, azi ), correctUV( v3.uv, v3, azi ) ] ); }