Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
break;
}
case 'y': {
value[componentName] = (convertToRightHandedSystem && useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
break;
}
case 'z': {
value[componentName] = (convertToRightHandedSystem && !useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
break;
}
case 'w': {
(value as Quaternion).w = factor;
break;
}
default: {
Tools.Error(`glTFAnimation: Unsupported component type "${componentName}" for scale animation!`);
}
}
}
return value;
}
public linkWithMesh(mesh: Nullable): void {
if (!this._host || this.parent && this.parent !== this._host._rootContainer) {
if (mesh) {
Tools.Error("Cannot link a control to a mesh if the control is not at root level");
}
return;
}
var index = this._host._linkedControls.indexOf(this);
if (index !== -1) {
this._linkedMesh = mesh;
if (!mesh) {
this._host._linkedControls.splice(index, 1);
}
return;
} else if (!mesh) {
return;
}
this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
index = x * stride;
(vertexData as Vector4[]).push(Vector4.FromArray(meshAttributeArray, index));
vertexBuffer.getSize() === 4 ? (vertexData as Vector4[]).push(Vector4.FromArray(meshAttributeArray, index)) : (vertexData as Vector3[]).push(Vector3.FromArray(meshAttributeArray, index));
}
break;
}
case VertexBuffer.UVKind:
case VertexBuffer.UV2Kind: {
for (let x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) {
index = x * stride;
(vertexData as Vector2[]).push(Vector2.FromArray(meshAttributeArray, index));
}
break;
}
default: {
Tools.Error(`Unsupported Vertex Buffer type: ${vertexBufferKind}`);
}
}
this.writeVertexAttributeData(vertexData, byteOffset, vertexBufferKind, meshAttributeArray, binaryWriter);
}
else {
Tools.Warn(`reorderTriangleFanMode: Vertex buffer kind ${vertexBufferKind} not present!`);
}
}
public setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void {
if (byteOffset + 12 > this._byteOffset) {
Tools.Error(`BinaryWriter: byteoffset is greater than the current binary buffer length!`);
}
else {
this._dataView.setFloat32(byteOffset, vector4.x, true);
this._dataView.setFloat32(byteOffset + 4, vector4.y, true);
this._dataView.setFloat32(byteOffset + 8, vector4.z, true);
this._dataView.setFloat32(byteOffset + 12, vector4.w, true);
}
}
/**
public moveToVector3(position: Vector3, scene: Scene): void {
if (!this._host || this.parent !== this._host._rootContainer) {
Tools.Error("Cannot move a control to a vector3 if the control is not at root level");
return;
}
this.horizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
this.verticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
var globalViewport = this._host._getGlobalViewport(scene);
var projectedPosition = Vector3.Project(position, Matrix.Identity(), scene.getTransformMatrix(), globalViewport);
this._moveToProjectedPosition(projectedPosition);
if (projectedPosition.z < 0 || projectedPosition.z > 1) {
this.notRenderable = true;
return;
}
this.notRenderable = false;
}
}
break;
}
case VertexBuffer.UVKind:
case VertexBuffer.UV2Kind: {
for (let x = submesh.verticesStart; x < submesh.verticesStart + submesh.verticesCount; x = x + 3) {
index = x * stride;
(vertexData as Vector2[]).push(Vector2.FromArray(meshAttributeArray, index));
(vertexData as Vector2[]).push(Vector2.FromArray(meshAttributeArray, index + 2 * stride));
(vertexData as Vector2[]).push(Vector2.FromArray(meshAttributeArray, index + stride));
}
break;
}
default: {
Tools.Error(`Unsupported Vertex Buffer type: ${vertexBufferKind}`);
}
}
this.writeVertexAttributeData(vertexData, byteOffset, vertexBufferKind, meshAttributeArray, binaryWriter);
}
}
else {
Tools.Warn(`reorderTriangleFillMode: Vertex Buffer Kind ${vertexBufferKind} not present!`);
}
}
public setFloat32(entry: number, byteOffset?: number) {
if (isNaN(entry)) {
Tools.Error('Invalid data being written!');
}
if (byteOffset != null) {
if (byteOffset < this._byteOffset) {
this._dataView.setFloat32(byteOffset, entry, true);
}
else {
Tools.Error('BinaryWriter: byteoffset is greater than the current binary length!');
}
}
if (this._byteOffset + 4 > this._arrayBuffer.byteLength) {
this.resizeBuffer(this._arrayBuffer.byteLength * 2);
}
this._dataView.setFloat32(this._byteOffset, entry, true);
this._byteOffset += 4;
}
/**
case GLTFLoaderAnimationStartMode.FIRST: {
const babylonAnimationGroups = this._getAnimationGroups();
if (babylonAnimationGroups.length !== 0) {
babylonAnimationGroups[0].start(true);
}
break;
}
case GLTFLoaderAnimationStartMode.ALL: {
const babylonAnimationGroups = this._getAnimationGroups();
for (const babylonAnimationGroup of babylonAnimationGroups) {
babylonAnimationGroup.start(true);
}
break;
}
default: {
Tools.Error(`Invalid animation start mode (${this._parent.animationStartMode})`);
return;
}
}
}
break;
}
case 'y': {
value[componentName] = (convertToRightHandedSystem && useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
break;
}
case 'z': {
value[componentName] = (convertToRightHandedSystem && !useQuaternion && (animationChannelTargetPath !== AnimationChannelTargetPath.SCALE)) ? -factor : factor;
break;
}
case 'w': {
(value as Quaternion).w = factor;
break;
}
default: {
Tools.Error(`glTFAnimation: Unsupported component type "${componentName}" for scale animation!`);
}
}
}
return value;
}
public moveToVector3(position: Vector3, scene: Scene, end: boolean = false): void {
if (!this._host || this.parent !== this._host._rootContainer) {
Tools.Error("Cannot move a control to a vector3 if the control is not at root level");
return;
}
var globalViewport = this._host._getGlobalViewport(scene);
var projectedPosition = Vector3.Project(position, Matrix.Identity(), scene.getTransformMatrix(), globalViewport);
this._moveToProjectedPosition(projectedPosition, end);
if (projectedPosition.z < 0 || projectedPosition.z > 1) {
this.notRenderable = true;
return;
}
this.notRenderable = false;
}