mirror of
https://github.com/storytold/spark.git
synced 2026-10-21 08:06:45 +00:00
Add types to SparkRenderer (#53)
This commit is contained in:
committed by
GitHub
parent
1ddbccc372
commit
aca62084d6
@@ -43,19 +43,19 @@ let hasSparkRenderer = false;
|
|||||||
|
|
||||||
let sparkRendererInstance: SparkRenderer;
|
let sparkRendererInstance: SparkRenderer;
|
||||||
|
|
||||||
function containsSplatMesh(object3D) {
|
function containsSplatMesh(object3D: THREE.Object3D) {
|
||||||
let hasSplatMesh = false;
|
let hasSplatMesh = false;
|
||||||
if (object3D instanceof SplatMesh) {
|
if (object3D instanceof SplatMesh) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
object3D.traverse((child) => {
|
object3D.traverse((child: THREE.Object3D) => {
|
||||||
hasSplatMesh = hasSplatMesh || child instanceof SplatMesh;
|
hasSplatMesh = hasSplatMesh || child instanceof SplatMesh;
|
||||||
});
|
});
|
||||||
return hasSplatMesh;
|
return hasSplatMesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sceneAdd = THREE.Scene.prototype.add;
|
const sceneAdd = THREE.Scene.prototype.add;
|
||||||
THREE.Scene.prototype.add = function (object) {
|
THREE.Scene.prototype.add = function (object: THREE.Object3D) {
|
||||||
hasSplatMesh = hasSplatMesh || containsSplatMesh(object);
|
hasSplatMesh = hasSplatMesh || containsSplatMesh(object);
|
||||||
hasSparkRenderer = hasSparkRenderer || object instanceof SparkRenderer;
|
hasSparkRenderer = hasSparkRenderer || object instanceof SparkRenderer;
|
||||||
sceneAdd.call(this, object);
|
sceneAdd.call(this, object);
|
||||||
@@ -63,7 +63,9 @@ THREE.Scene.prototype.add = function (object) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const sceneOnBeforeRender = THREE.Scene.prototype.onBeforeRender;
|
const sceneOnBeforeRender = THREE.Scene.prototype.onBeforeRender;
|
||||||
THREE.Scene.prototype.onBeforeRender = function (renderer) {
|
THREE.Scene.prototype.onBeforeRender = function (
|
||||||
|
renderer: THREE.WebGLRenderer,
|
||||||
|
) {
|
||||||
if (!hasSplatMesh) {
|
if (!hasSplatMesh) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user