deep-engine-demo/packages/three-is
2026-04-19 18:46:28 +08:00
..
src feat(all): init commit 2026-04-19 18:46:28 +08:00
.gitignore feat(all): init commit 2026-04-19 18:46:28 +08:00
LICENSE feat(all): init commit 2026-04-19 18:46:28 +08:00
package.json feat(all): init commit 2026-04-19 18:46:28 +08:00
pnpm-lock.yaml feat(all): init commit 2026-04-19 18:46:28 +08:00
README.md feat(all): init commit 2026-04-19 18:46:28 +08:00
tsconfig.json feat(all): init commit 2026-04-19 18:46:28 +08:00

three-is

在 typescript 使用 three.js 时的类型守卫

import {isOrthographicCamera, isPerspectiveCamera} from "three-is";
import * as THREE from "three";

const camera: THREE.PerspectiveCamera | THREE.OrthographicCamera = new THREE.OrthographicCamera()

if (isOrthographicCamera(camera)) {
    // 为正交
} else if (isPerspectiveCamera(camera)) {
    // 为透视
}