Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/packages/editor-oss/src/EngineRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,7 @@ export class EngineRuntime extends AppRuntime implements RuntimeContext {
}

private createWebGPURenderer(overrideForceWebGL?: boolean): WebGPURenderer {
const forceWebGL = overrideForceWebGL ?? (this.editor?.scene?.userData?.rendering?.forceWebGL || false);
const forceWebGL = !true;
const useTransparentCanvas = !!(
this.editor?.scene?.userData?.cesium?.enabled || this.scene?.userData?.cesium?.enabled
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,6 @@ export function applyPoseToSkeleton(skeleton: THREE.Skeleton, pose: PoseTargets)
}

skeleton.calculateInverses();
skeleton.computeBoneTexture?.();

console.debug("[poseFit] applied pose to skeleton", {
appliedPairs: applied,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SparkGaussianSplatLoader extends BaseLoader {
async load(url: string, options?: SparkGaussianSplatLoaderOptions): Promise<Object3D> {
const resolvedUrl = this.resolveUrl(url);
const packedSplats = await this.getPackedSplats(resolvedUrl, options);
const mesh = new SplatMesh({ packedSplats });
const mesh = new SplatMesh({ packedSplats, editable: true });
await mesh.initialized;

mesh.userData.type = 'GaussianSplat';
Expand Down
36 changes: 35 additions & 1 deletion client/packages/editor-oss/src/editor/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3458,7 +3458,12 @@ class Editor {

getSelectionBoundaryObject(obj: THREE.Object3D): THREE.Object3D {
const billboardRoot = this.getBillboardSelectionRoot(obj);
return billboardRoot || obj;
if (billboardRoot) {
return billboardRoot;
}

const skinnedMeshRoot = this.getSkinnedMeshSelectionRoot(obj);
return skinnedMeshRoot || obj;
}

getBillboardSelectionRoot(obj: THREE.Object3D): THREE.Object3D | null {
Expand All @@ -3474,6 +3479,35 @@ class Editor {
return null;
}

getSkinnedMeshSelectionRoot(obj: THREE.Object3D): THREE.Object3D | null {
const skinnedMesh = (obj as THREE.SkinnedMesh).isSkinnedMesh ? obj as THREE.SkinnedMesh : null;
const skeletonRoot = skinnedMesh?.skeleton?.bones[0];

if (!skinnedMesh || !skeletonRoot) {
return null;
}

const skeletonAncestors = new Set<THREE.Object3D>();
let current: THREE.Object3D | null = skeletonRoot;

while (current) {
skeletonAncestors.add(current);
current = current.parent;
}

current = skinnedMesh.parent;
while (current && current.type !== "Scene") {
if (skeletonAncestors.has(current)) {
return current;
}
current = current.parent;
}

return skinnedMesh.parent && skinnedMesh.parent.type !== "Scene"
? skinnedMesh.parent
: null;
}

// Clear selection helper
clearSelection() {
if (Array.isArray(this.selected)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import { getObjectBoundingBox, isGaussianSplatObject } from '@stem/editor-oss/mo
import { disposeSparkComposite, ensureSparkComposite } from '../../../../../../../../render/SparkCompositeBridge';
import { positionCameraForModel } from "../../../../../utils/positionCameraForModel";

const PREVIEW_AMBIENT_INTENSITY = 1.8;
const PREVIEW_DIRECTIONAL_INTENSITY = 0.6;
const PREVIEW_ENVIRONMENT_INTENSITY = 0.45;

export class ModelPreviewRenderer {
renderer: WebGPURenderer;
scene: Scene;
Expand Down Expand Up @@ -71,11 +75,11 @@ export class ModelPreviewRenderer {

this.scene = new Scene();
this.scene.name = "ModelPreviewScene";
const light = new AmbientLight(0xffffff, 5);
const light = new AmbientLight(0xffffff, PREVIEW_AMBIENT_INTENSITY);
light.name = "AutoLight";
this.scene.add(light);

this.directionalLight = new DirectionalLight(0xffffff, 0.8);
this.directionalLight = new DirectionalLight(0xffffff, PREVIEW_DIRECTIONAL_INTENSITY);
this.directionalLight.position.set(5, 10, 7.5);
this.scene.add(this.directionalLight);

Expand All @@ -84,7 +88,7 @@ export class ModelPreviewRenderer {
(loadedTexture: Texture) => {
loadedTexture.mapping = EquirectangularReflectionMapping;
this.scene.environment = loadedTexture;
this.scene.environmentIntensity = 1.0;
this.scene.environmentIntensity = PREVIEW_ENVIRONMENT_INTENSITY;
},
undefined,
(error: unknown) => {
Expand Down Expand Up @@ -152,7 +156,7 @@ export class ModelPreviewRenderer {
depthMaterial,
};

this.sparkComposite = ensureSparkComposite(this.scene, this.renderer);
this.sparkComposite = null;
}

async init() {
Expand Down Expand Up @@ -180,6 +184,12 @@ export class ModelPreviewRenderer {
this.scene.add(this.model);
this.model.updateMatrixWorld(true);
this.isGaussianSplatModel = isGaussianSplatObject(this.model);
if (this.isGaussianSplatModel) {
this.sparkComposite = ensureSparkComposite(this.scene, this.renderer);
} else if (this.sparkComposite) {
disposeSparkComposite(this.sparkComposite);
this.sparkComposite = null;
}
this.cameraWarmupFramesRemaining = this.isGaussianSplatModel ? 45 : 0;

positionCameraForModel(this.model, this.camera, this.controls);
Expand Down Expand Up @@ -309,6 +319,7 @@ export class ModelPreviewRenderer {
this.model = undefined;
}
disposeSparkComposite(this.sparkComposite);
this.sparkComposite = null;
this.renderer.dispose();
this.scene.clear();
this.controls.dispose();
Expand Down
Loading
Loading