Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this,
{
type: RIGID_BODY,
awake: true,
lineardrag: 0.999,
dynamic: true,
velocity: vec3.create(),
acceleration: vec3.create(),
position: vec3.create(),
force: vec3.create(),
},
params
);
// copy mesh position
vec3.copy(this.position, this.mesh.position.data);
}
set(origin, end) {
// Compute direction
const direction = vec3.create();
vec3.subtract(direction, end, origin);
// Copy
vec3.copy(this.origin, origin);
vec3.copy(this.direction, direction);
// Compute inverse direction
for (let i = 0; i < 3; i += 1) {
this.invDirection[i] = 1.0 / direction[i];
this.signs[i] = (this.invDirection[i] < 0) ? 1 : 0;
}
}
}
let type = (actor.parameters & 0x3F);
if (type === 0x3F)
type = 0;
setModelMatrix(actor, scratchMat4a);
vec3.set(scratchVec3a, 0, 0, 0);
if (type === 0 || type === 3) {
const rarc = context.modelCache.getObjectData(`Ep`);
const m = buildModel(context, rarc, obm ? `bdl/obm_shokudai1.bdl` : `bdl/vktsd.bdl`, actor);
scratchVec3a[1] += 140;
}
vec3.transformMat4(scratchVec3a, scratchVec3a, scratchMat4a);
// Create particle systems.
const pa = createEmitter(context, 0x0001);
vec3.copy(pa.globalTranslation, scratchVec3a);
pa.globalTranslation[1] += -240 + 235 + 15;
if (type !== 2) {
const pb = createEmitter(context, 0x4004);
vec3.copy(pb.globalTranslation, pa.globalTranslation);
pb.globalTranslation[1] += 20;
}
const pc = createEmitter(context, 0x01EA);
vec3.copy(pc.globalTranslation, scratchVec3a);
pc.globalTranslation[1] += -240 + 235 + 8;
// TODO(jstpierre): ga
}
let scale = node.worldScale;
let width = widthHeap[0] * 0.5;
let length = lengthHeap[0] * 0.5;
let latitude = degToRad(latitudeHeap[0]);
let variation = variationHeap[0];
let speed = speedHeap[0];
let location = this.location;
let velocity = this.velocity;
this.emitterView = emitterView;
this.node = node;
this.health = modelObject.lifeSpan;
this.head = isHead;
this.gravity = gravityHeap[0] * scale[2];
vec3.copy(this.nodeScale, scale);
// Local location
location[0] = pivot[0] + randomInRange(-width, width);
location[1] = pivot[1] + randomInRange(-length, length);
location[2] = pivot[2];
// World location
if (!modelObject.modelSpace) {
vec3.transformMat4(location, location, node.worldMatrix);
}
// Local rotation
quat.identity(rotationHeap);
quat.rotateZ(rotationHeap, rotationHeap, Math.PI / 2);
quat.rotateY(rotationHeap, rotationHeap, randomInRange(-latitude, latitude));
setTrans(trans) {
vec3.copy(this._trans, trans);
if (this._projectionType === Enums.Projection.ORTHOGRAPHIC)
this.updateOrtho();
this.updateView();
}
fillPosition: (dst: vec3, i: number) => vec3.copy(dst, vertices[i].pos),
fillTexCoord: (dst: vec2, i: number) => vec2.set(dst, vertices[i].pos[0] / 32, vertices[i].pos[1] / 32),
const anmTrans = scratchVec3b;
const anmRot = scratchQuat;
vec3.set(anmScale, scaleX, scaleY, scaleZ);
vec3.set(anmTrans, translationX, translationY, translationZ);
quatFromEulerRadians(anmRot, rotationX, rotationY, rotationZ);
if (this.resetJointXform)
xj.xformFrozen.copy(xj.xformAnm);
if (this.interpoleRatio < 1.0) {
vec3.lerp(anmScale, xj.xformFrozen.scale, anmScale, this.interpoleRatio);
vec3.lerp(anmTrans, xj.xformFrozen.translation, anmTrans, this.interpoleRatio);
quat.lerp(anmRot, xj.xformFrozen.rotation, scratchQuat, this.interpoleRatio);
}
vec3.copy(xj.xformAnm.scale, anmScale);
vec3.copy(xj.xformAnm.translation, anmTrans);
quat.copy(xj.xformAnm.rotation, anmRot);
}
}
const anmRot = scratchQuat;
vec3.set(anmScale, scaleX, scaleY, scaleZ);
vec3.set(anmTrans, translationX, translationY, translationZ);
quatFromEulerRadians(anmRot, rotationX, rotationY, rotationZ);
if (this.resetJointXform)
xj.xformFrozen.copy(xj.xformAnm);
if (this.interpoleRatio < 1.0) {
vec3.lerp(anmScale, xj.xformFrozen.scale, anmScale, this.interpoleRatio);
vec3.lerp(anmTrans, xj.xformFrozen.translation, anmTrans, this.interpoleRatio);
quat.lerp(anmRot, xj.xformFrozen.rotation, scratchQuat, this.interpoleRatio);
}
vec3.copy(xj.xformAnm.scale, anmScale);
vec3.copy(xj.xformAnm.translation, anmTrans);
quat.copy(xj.xformAnm.rotation, anmRot);
}
}
this.moveConditionType = getMapPartsArgMoveConditionType(infoIter);
this.moveStopType = getMapPartsArgMoveStopType(this.actor);
this.signMotionType = getMapPartsArgSignMotionType(infoIter);
const initPosType = getMapPartsArgRailInitPosType(this.actor);
if (initPosType === RailInitPosType.NearestPos) {
moveCoordAndTransToNearestRailPos(this.actor);
} else if (initPosType === RailInitPosType.NearestPoint) {
moveCoordAndTransToNearestRailPoint(this.actor);
} else if (initPosType === RailInitPosType.Point0) {
moveCoordAndTransToRailStartPoint(this.actor);
}
vec3.copy(this.translation, this.actor.translation);
this.startRailCoord = getRailCoord(this.actor);
this.spine.setNerve(MapPartsRailMoverNrv.Wait);
}
upRightNormal() {
const up = vec4.create()
vec4.set(up, 0, 1, 0, 0)
vec4.transformMat4(up, up, this.matrix)
vec3.copy(this.up, up)
const right = vec4.create()
vec4.set(right, 1, 0, 0, 0)
vec4.transformMat4(right, right, this.matrix)
vec3.copy(this.right, right)
const normal = vec4.create()
vec4.set(normal, 0, 0, 1, 0)
vec4.transformMat4(normal, normal, this.matrix)
vec3.copy(this.normal, normal)
}