本文整理汇总了TypeScript中THREE.Vector3.copy方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Vector3.copy方法的具体用法?TypeScript Vector3.copy怎么用?TypeScript Vector3.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类THREE.Vector3
的用法示例。
在下文中一共展示了Vector3.copy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: projectPointOnVector
structure.eachAtom(function (ap: AtomProxy) {
projectPointOnVector(p.copy(ap as any), ax1, center) // TODO
const dp1 = t.subVectors(p, center).normalize().dot(ax1)
const dt1 = p.distanceTo(center)
if (dp1 > 0) {
if (dt1 > d1a) d1a = dt1
} else {
if (dt1 > d1b) d1b = dt1
}
projectPointOnVector(p.copy(ap as any), ax2, center)
const dp2 = t.subVectors(p, center).normalize().dot(ax2)
const dt2 = p.distanceTo(center)
if (dp2 > 0) {
if (dt2 > d2a) d2a = dt2
} else {
if (dt2 > d2b) d2b = dt2
}
projectPointOnVector(p.copy(ap as any), ax3, center)
const dp3 = t.subVectors(p, center).normalize().dot(ax3)
const dt3 = p.distanceTo(center)
if (dp3 > 0) {
if (dt3 > d3a) d3a = dt3
} else {
if (dt3 > d3b) d3b = dt3
}
})
示例2: update
update(world: World, control: Control) {
var beta = control.motionTracker.getBeta();
this._acceleration.copy(this._speed).divideScalar(30).clampLength(0.1, 3);
this._acceleration.applyAxisAngle(yAxis, horizontalRotation(beta));
this._speed.add(this._acceleration);
this._speed.clampLength(0, 80);
var newPos = new Vector3().addVectors(this._position, this._speed);
this._playerTracker.updateSection(newPos);
var collision = this._playerTracker.getCollision();
if (collision) {
newPos = collision;
this._speed.multiplyScalar(0.3);
newPos = this._playerTracker.getAdjusted(newPos);
this._position.copy(newPos);
} else {
newPos = this._playerTracker.getAdjusted(newPos);
this._acceleration.subVectors(newPos, this._position).sub(this._speed).clampLength(0, 5);
this._speed.add(this._acceleration);
this._position.add(this._speed);
}
this._direction.setFromUnitVectors(
new Vector3(0, 0, 1),
this._speed.clone().setY(0).setLength(1));
}
示例3: _applyRotation
private _applyRotation(camera: Camera): void {
if (camera == null) {
return;
}
let q: THREE.Quaternion = new THREE.Quaternion().setFromUnitVectors(camera.up, new THREE.Vector3( 0, 0, 1 ));
let qInverse: THREE.Quaternion = q.clone().inverse();
let offset: THREE.Vector3 = new THREE.Vector3();
offset.copy(camera.lookat).sub(camera.position);
offset.applyQuaternion(q);
let length: number = offset.length();
let phi: number = Math.atan2(offset.y, offset.x);
phi += this._rotationDelta.phi;
let theta: number = Math.atan2(Math.sqrt(offset.x * offset.x + offset.y * offset.y), offset.z);
theta += this._rotationDelta.theta;
theta = Math.max(0.1, Math.min(Math.PI - 0.1, theta));
offset.x = Math.sin(theta) * Math.cos(phi);
offset.y = Math.sin(theta) * Math.sin(phi);
offset.z = Math.cos(theta);
offset.applyQuaternion(qInverse);
camera.lookat.copy(camera.position).add(offset.multiplyScalar(length));
}
示例4: function
return function( deltaX, deltaY ) {
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
if ( scope.object instanceof three.PerspectiveCamera ) {
// perspective
var position = scope.object.position;
offset.copy( position ).sub( scope.target );
var targetDistance = offset.length();
// half of the fov is center to top of screen
targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
// we actually don't use screenWidth, since perspective camera is fixed to screen height
panLeft( 2 * deltaX * targetDistance / element.clientHeight, scope.object.matrix );
panUp( 2 * deltaY * targetDistance / element.clientHeight, scope.object.matrix );
} else if ( scope.object instanceof three.OrthographicCamera ) {
// orthographic
panLeft( deltaX * ( scope.object.right - scope.object.left ) / scope.object.zoom / element.clientWidth, scope.object.matrix );
panUp( deltaY * ( scope.object.top - scope.object.bottom ) / scope.object.zoom / element.clientHeight, scope.object.matrix );
} else {
// camera neither orthographic nor perspective
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
scope.enablePan = false;
}
};
示例5: _update
_update () {
if (!this.getVisibility()) return
const s = this.element.style
const cp = this._canvasPosition
const vp = this._viewerPosition
const cr = this._clientRect
this._cameraPosition.copy(vp)
.add(this.viewer.translationGroup.position)
.applyMatrix4(this.viewer.rotationGroup.matrix)
.sub(this.viewer.camera.position)
if (this._cameraPosition.z < 0) {
s.display = 'none'
return
} else {
s.display = 'block'
}
const depth = this._cameraPosition.length()
const fog = this.viewer.scene.fog as any // TODO
s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()
s.zIndex = (Math.round((fog.far - depth) * 100)).toString()
this.stage.viewerControls.getPositionOnCanvas(vp, cp)
s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'
s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'
}
示例6: setPosition
setPosition(position: Vector3) {
this.position.copy(position);
this.mesh.position.copy(position);
if (this.halo) {
this.halo.position.copy(position);
}
}
示例7: setParameters
/**
* Set representation parameters
* @alias SurfaceRepresentation#setParameters
* @param {SurfaceRepresentationParameters} params - surface parameter object
* @param {Object} [what] - buffer data attributes to be updated,
* note that this needs to be implemented in the
* derived classes. Generally it allows more
* fine-grained control over updating than
* forcing a rebuild.
* @param {Boolean} what.position - update position data
* @param {Boolean} what.color - update color data
* @param {Boolean} [rebuild] - whether or not to rebuild the representation
* @return {SurfaceRepresentation} this object
*/
setParameters (params: Partial<SurfaceRepresentationParameters>, what?: SurfaceDataFields, rebuild?: boolean) {
if (params && params.isolevelType !== undefined &&
this.volume
) {
if (this.isolevelType === 'value' &&
params.isolevelType === 'sigma'
) {
this.isolevel = this.volume.getSigmaForValue(this.isolevel)
} else if (this.isolevelType === 'sigma' &&
params.isolevelType === 'value'
) {
this.isolevel = this.volume.getValueForSigma(this.isolevel)
}
this.isolevelType = params.isolevelType
}
if (params && params.boxCenter) {
this.boxCenter.copy(params.boxCenter)
delete params.boxCenter
}
// Forbid wireframe && contour as in molsurface
if (params && params.wireframe && (
params.contour || (params.contour === undefined && this.contour)
)) {
params.wireframe = false
}
super.setParameters(params, what, rebuild)
if (this.volume) {
this.volume.getBox(this.boxCenter, this.boxSize, this.box)
}
if (params && params.colorVolume !== undefined) {
if (what) what.color = true
}
if (this.surface && (
params.isolevel !== undefined ||
params.negateIsolevel !== undefined ||
params.smooth !== undefined ||
params.wrap !== undefined ||
params.boxSize !== undefined ||
(this.boxSize > 0 &&
!this.__box.equals(this.box))
)) {
this.build({
'position': true,
'color': true,
'index': true,
'normal': !this.contour
})
}
return this
}
示例8: prepare
prepare (callback: () => void) {
if (this.volume) {
let isolevel
if (this.isolevelType === 'sigma') {
isolevel = this.volume.getValueForSigma(this.isolevel)
} else {
isolevel = this.isolevel
}
if (this.negateIsolevel) isolevel *= -1
if (!this.surface ||
this.__isolevel !== isolevel ||
this.__smooth !== this.smooth ||
this.__contour !== this.contour ||
this.__wrap !== this.wrap ||
this.__boxSize !== this.boxSize ||
(this.boxSize > 0 &&
!this.__boxCenter.equals(this.boxCenter))
) {
this.__isolevel = isolevel
this.__smooth = this.smooth
this.__contour = this.contour
this.__wrap = this.wrap
this.__boxSize = this.boxSize
this.__boxCenter.copy(this.boxCenter)
this.__box.copy(this.box)
const onSurfaceFinish = (surface: Surface) => {
this.surface = surface
callback()
}
if (this.useWorker) {
this.volume.getSurfaceWorker(
isolevel, this.smooth, this.boxCenter, this.boxSize,
this.contour, this.wrap, onSurfaceFinish
)
} else {
onSurfaceFinish(
this.volume.getSurface(
isolevel, this.smooth, this.boxCenter, this.boxSize,
this.contour, this.wrap
)
)
}
} else {
callback()
}
} else {
callback()
}
}
示例9: handleVertex
function handleVertex(v) {
n.fromArray(normals, v * 3);
n2.copy(n);
t = tan1[v];
// Gram-Schmidt orthogonalize
tmp.copy(t);
tmp.sub(n.multiplyScalar(n.dot(t))).normalize();
// Calculate handedness
tmp2.crossVectors(n2, t);
test = tmp2.dot(tan2[v]);
w = (test < 0.0) ? - 1.0 : 1.0;
tangents[v * 4] = tmp.x;
tangents[v * 4 + 1] = tmp.y;
tangents[v * 4 + 2] = tmp.z;
tangents[v * 4 + 3] = w;
}