當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript types.Nullable類代碼示例

本文整理匯總了TypeScript中babylonjs/types.Nullable的典型用法代碼示例。如果您正苦於以下問題:TypeScript Nullable類的具體用法?TypeScript Nullable怎麽用?TypeScript Nullable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Nullable類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: mesh

    public set mesh(value: Nullable<AbstractMesh>) {
        if (this._mesh === value) {
            return;
        }

        if (this._mesh && this._meshObserver) {
            this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver);
        }

        this._mesh = value;

        if (this._mesh) {
            this._meshObserver = this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate);
        }

        this._multiLine._markAsDirty();
    }
開發者ID:BabylonJS,項目名稱:Babylon.js,代碼行數:17,代碼來源:multiLinePoint.ts

示例2: _AddKeyframeValue

    /**
     * Adds a key frame value
     * @param keyFrame
     * @param animation
     * @param outputs
     * @param animationChannelTargetPath
     * @param basePositionRotationOrScale
     * @param convertToRightHandedSystem
     * @param useQuaternion
     */
    private static _AddKeyframeValue(keyFrame: IAnimationKey, animation: Animation, outputs: number[][], animationChannelTargetPath: AnimationChannelTargetPath, babylonTransformNode: TransformNode, convertToRightHandedSystem: boolean, useQuaternion: boolean) {
        let value: number[];
        let newPositionRotationOrScale: Nullable<Vector3 | Quaternion>;
        const animationType = animation.dataType;
        if (animationType === Animation.ANIMATIONTYPE_VECTOR3) {
            value = keyFrame.value.asArray();
            if (animationChannelTargetPath === AnimationChannelTargetPath.ROTATION) {
                const array = Vector3.FromArray(value);
                let rotationQuaternion = Quaternion.RotationYawPitchRoll(array.y, array.x, array.z);
                if (convertToRightHandedSystem) {
                    _GLTFUtilities._GetRightHandedQuaternionFromRef(rotationQuaternion);

                    if (!babylonTransformNode.parent) {
                        rotationQuaternion = Quaternion.FromArray([0, 1, 0, 0]).multiply(rotationQuaternion);
                    }
                }
                value = rotationQuaternion.asArray();
            }
            else if (animationChannelTargetPath === AnimationChannelTargetPath.TRANSLATION) {
                if (convertToRightHandedSystem) {
                    _GLTFUtilities._GetRightHandedNormalArray3FromRef(value);
                    if (!babylonTransformNode.parent) {
                        value[0] *= -1;
                        value[2] *= -1;
                    }
                }
            }
            outputs.push(value); // scale  vector.

        }
        else if (animationType === Animation.ANIMATIONTYPE_FLOAT) { // handles single component x, y, z or w component animation by using a base property and animating over a component.
            newPositionRotationOrScale = this._ConvertFactorToVector3OrQuaternion(keyFrame.value as number, babylonTransformNode, animation, animationType, animationChannelTargetPath, convertToRightHandedSystem, useQuaternion);
            if (newPositionRotationOrScale) {
                if (animationChannelTargetPath === AnimationChannelTargetPath.ROTATION) {
                    let posRotScale = useQuaternion ? newPositionRotationOrScale as Quaternion : Quaternion.RotationYawPitchRoll(newPositionRotationOrScale.y, newPositionRotationOrScale.x, newPositionRotationOrScale.z).normalize();
                    if (convertToRightHandedSystem) {
                        _GLTFUtilities._GetRightHandedQuaternionFromRef(posRotScale);

                        if (!babylonTransformNode.parent) {
                            posRotScale = Quaternion.FromArray([0, 1, 0, 0]).multiply(posRotScale);
                        }
                    }
                    outputs.push(posRotScale.asArray());
                }
                else if (animationChannelTargetPath === AnimationChannelTargetPath.TRANSLATION) {
                    if (convertToRightHandedSystem) {
                        _GLTFUtilities._GetRightHandedNormalVector3FromRef(newPositionRotationOrScale as Vector3);

                        if (!babylonTransformNode.parent) {
                            newPositionRotationOrScale.x *= -1;
                            newPositionRotationOrScale.z *= -1;
                        }
                    }
                }
                outputs.push(newPositionRotationOrScale.asArray());
            }
        }
        else if (animationType === Animation.ANIMATIONTYPE_QUATERNION) {
            value = (keyFrame.value as Quaternion).normalize().asArray();

            if (convertToRightHandedSystem) {
                _GLTFUtilities._GetRightHandedQuaternionArrayFromRef(value);

                if (!babylonTransformNode.parent) {
                    value = Quaternion.FromArray([0, 1, 0, 0]).multiply(Quaternion.FromArray(value)).asArray();
                }
            }

            outputs.push(value);
        }
        else {
            Tools.Error('glTFAnimation: Unsupported key frame values for animation!');
        }
    }
開發者ID:Pryme8,項目名稱:Babylon.js,代碼行數:84,代碼來源:glTFAnimation.ts

示例3: _translatePoint

    private _translatePoint(): Vector2 {
        if (this._mesh != null) {
            return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center, this._mesh.getWorldMatrix());
        }
        else if (this._control != null) {
            return new Vector2(this._control.centerX, this._control.centerY);
        }
        else {
            var host: any = this._multiLine._host as any;

            var xValue: number = this._x.getValueInPixel(host, Number(host._canvas.width));
            var yValue: number = this._y.getValueInPixel(host, Number(host._canvas.height));

            return new Vector2(xValue, yValue);
        }
    }
開發者ID:BabylonJS,項目名稱:Babylon.js,代碼行數:16,代碼來源:multiLinePoint.ts


注:本文中的babylonjs/types.Nullable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。