#5905 Cleanup console warnings (#5908)

* Fix ToolBar WebkitAppRegion warning

* make intersectionPlane non-nullable, avoid trying to create it multiple times to get rid of warning

* remove derived scene from sceneEntities

* intersectionPlane is now always non-null, make it readonly too

* sceneInfra small cleanups

* A snapshot a day keeps the bugs away! 📷🐛

* A snapshot a day keeps the bugs away! 📷🐛

* Clean up snapshots

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Pierre Jacquier <pierre@zoo.dev>
This commit is contained in:
Andrew Varga
2025-03-21 01:55:20 +01:00
committed by GitHub
parent 054bb5b500
commit 9248b2e42d
4 changed files with 73 additions and 86 deletions

View File

@ -392,7 +392,8 @@ const ToolbarItemTooltip = memo(function ToolbarItemContents({
inert={false}
wrapperStyle={
isDesktop()
? ({ '-webkit-app-region': 'no-drag' } as React.CSSProperties)
? // Without this, the tooltip disappears before being able to click on anything in it
({ WebkitAppRegion: 'no-drag' } as React.CSSProperties)
: {}
}
hoverOnly

View File

@ -12,7 +12,6 @@ import {
PlaneGeometry,
Points,
Quaternion,
Scene,
Vector2,
Vector3,
Shape,
@ -189,19 +188,17 @@ type Vec3Array = [number, number, number]
// That mostly mean sketch elements.
// Cameras, controls, raycasters, etc are handled by sceneInfra
export class SceneEntities {
engineCommandManager: EngineCommandManager
scene: Scene
readonly engineCommandManager: EngineCommandManager
activeSegments: { [key: string]: Group } = {}
intersectionPlane: Mesh | null = null
readonly intersectionPlane: Mesh
axisGroup: Group | null = null
draftPointGroups: Group[] = []
currentSketchQuaternion: Quaternion | null = null
constructor(engineCommandManager: EngineCommandManager) {
this.engineCommandManager = engineCommandManager
this.scene = sceneInfra?.scene
sceneInfra?.camControls.subscribeToCamChange(this.onCamChange)
this.intersectionPlane = SceneEntities.createIntersectionPlane()
sceneInfra.camControls.subscribeToCamChange(this.onCamChange)
window.addEventListener('resize', this.onWindowResize)
this.createIntersectionPlane()
}
onWindowResize = () => {
@ -328,11 +325,7 @@ export class SceneEntities {
sceneInfra.overlayCallbacks(callbacks)
}
createIntersectionPlane() {
if (sceneInfra.scene.getObjectByName(RAYCASTABLE_PLANE)) {
console.warn('createIntersectionPlane called when it already exists')
return
}
private static createIntersectionPlane() {
const hundredM = 100_0000
const planeGeometry = new PlaneGeometry(hundredM, hundredM)
const planeMaterial = new MeshBasicMaterial({
@ -341,11 +334,12 @@ export class SceneEntities {
transparent: true,
opacity: 0.5,
})
this.intersectionPlane = new Mesh(planeGeometry, planeMaterial)
this.intersectionPlane.userData = { type: RAYCASTABLE_PLANE }
this.intersectionPlane.name = RAYCASTABLE_PLANE
this.intersectionPlane.layers.set(INTERSECTION_PLANE_LAYER)
this.scene.add(this.intersectionPlane)
const intersectionPlane = new Mesh(planeGeometry, planeMaterial)
intersectionPlane.userData = { type: RAYCASTABLE_PLANE }
intersectionPlane.name = RAYCASTABLE_PLANE
intersectionPlane.layers.set(INTERSECTION_PLANE_LAYER)
sceneInfra.scene.add(intersectionPlane)
return intersectionPlane
}
createSketchAxis(
sketchPathToNode: PathToNode,
@ -424,10 +418,10 @@ export class SceneEntities {
)
this.axisGroup.setRotationFromQuaternion(quat)
sketchPosition && this.axisGroup.position.set(...sketchPosition)
this.scene.add(this.axisGroup)
sceneInfra.scene.add(this.axisGroup)
}
getDraftPoint() {
return this.scene.getObjectByName(DRAFT_POINT)
return sceneInfra.scene.getObjectByName(DRAFT_POINT)
}
createDraftPoint({
point,
@ -453,7 +447,7 @@ export class SceneEntities {
new Vector3(...zAxis)
)
draftPointGroup.setRotationFromQuaternion(currentSketchQuaternion)
this.scene.add(draftPointGroup)
sceneInfra.scene.add(draftPointGroup)
const dummy = new Mesh()
dummy.position.set(0, 0, 0)
const scale = sceneInfra.getClientSceneScaleFactor(dummy)
@ -505,8 +499,8 @@ export class SceneEntities {
)
// Position the click raycast plane
this.intersectionPlane!.setRotationFromQuaternion(quaternion)
this.intersectionPlane!.position.copy(
this.intersectionPlane.setRotationFromQuaternion(quaternion)
this.intersectionPlane.position.copy(
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
)
sceneInfra.setCallbacks({
@ -658,8 +652,6 @@ export class SceneEntities {
truncatedAst: Node<Program>
variableDeclarationName: string
}> {
this.createIntersectionPlane()
const prepared = this.prepareTruncatedAst(sketchNodePaths, maybeModdedAst)
if (err(prepared)) return Promise.reject(prepared)
const { truncatedAst, variableDeclarationName } = prepared
@ -847,14 +839,11 @@ export class SceneEntities {
new Vector3(...forward)
)
group.setRotationFromQuaternion(this.currentSketchQuaternion)
this.intersectionPlane &&
this.intersectionPlane.setRotationFromQuaternion(
this.currentSketchQuaternion
)
this.intersectionPlane &&
position &&
this.intersectionPlane.position.set(...position)
this.scene.add(group)
position && this.intersectionPlane.position.set(...position)
sceneInfra.scene.add(group)
sceneInfra.camControls.enableRotate = false
sceneInfra.overlayCallbacks(callbacks)
@ -3059,18 +3048,18 @@ export class SceneEntities {
})
}
removeSketchGrid() {
if (this.axisGroup) this.scene.remove(this.axisGroup)
if (this.axisGroup) sceneInfra.scene.remove(this.axisGroup)
}
tearDownSketch({ removeAxis = true }: { removeAxis?: boolean }) {
// Remove all draft groups
this.draftPointGroups.forEach((draftPointGroup) => {
this.scene.remove(draftPointGroup)
sceneInfra.scene.remove(draftPointGroup)
})
// Remove all sketch tools
if (this.axisGroup && removeAxis) this.scene.remove(this.axisGroup)
const sketchSegments = this.scene.children.find(
if (this.axisGroup && removeAxis) sceneInfra.scene.remove(this.axisGroup)
const sketchSegments = sceneInfra.scene.children.find(
({ userData }) => userData?.type === SKETCH_GROUP_SEGMENTS
)
if (sketchSegments) {
@ -3082,7 +3071,7 @@ export class SceneEntities {
object.remove()
}
})
this.scene.remove(sketchSegments)
sceneInfra.scene.remove(sketchSegments)
}
sceneInfra.camControls.enableRotate = true
this.activeSegments = {}

View File

@ -110,18 +110,16 @@ interface OnMoveCallbackArgs {
type Voidish = void | Promise<void>
export class SceneInfra {
static instance: SceneInfra
scene: Scene
renderer: WebGLRenderer
labelRenderer: CSS2DRenderer
camControls: CameraControls
isPerspective = true
fov = 45
fovBeforeAnimate = 45
readonly scene: Scene
readonly renderer: WebGLRenderer
readonly labelRenderer: CSS2DRenderer
readonly camControls: CameraControls
private readonly fov = 45
isFovAnimationInProgress = false
_baseUnit: BaseUnit = 'mm'
_baseUnitMultiplier = 1
_theme: Themes = Themes.System
extraSegmentTexture: Texture
readonly extraSegmentTexture: Texture
lastMouseState: MouseState = { type: 'idle' }
onDragStartCallback: (arg: OnDragCallbackArgs) => Voidish = () => {}
onDragEndCallback: (arg: OnDragCallbackArgs) => Voidish = () => {}

View File

@ -870,14 +870,14 @@ export const modelingMachine = setup({
)
// Position the click raycast plane
if (sceneEntitiesManager.intersectionPlane) {
sceneEntitiesManager.intersectionPlane.setRotationFromQuaternion(
quaternion
)
sceneEntitiesManager.intersectionPlane.position.copy(
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
)
}
sceneInfra.setCallbacks({
onClick: (args) => {
if (!args) return
@ -906,14 +906,14 @@ export const modelingMachine = setup({
)
// Position the click raycast plane
if (sceneEntitiesManager.intersectionPlane) {
sceneEntitiesManager.intersectionPlane.setRotationFromQuaternion(
quaternion
)
sceneEntitiesManager.intersectionPlane.position.copy(
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
)
}
sceneInfra.setCallbacks({
onClick: (args) => {
if (!args) return
@ -939,14 +939,14 @@ export const modelingMachine = setup({
)
// Position the click raycast plane
if (sceneEntitiesManager.intersectionPlane) {
sceneEntitiesManager.intersectionPlane.setRotationFromQuaternion(
quaternion
)
sceneEntitiesManager.intersectionPlane.position.copy(
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
)
}
sceneInfra.setCallbacks({
onClick: (args) => {
if (!args) return
@ -973,14 +973,14 @@ export const modelingMachine = setup({
)
// Position the click raycast plane
if (sceneEntitiesManager.intersectionPlane) {
sceneEntitiesManager.intersectionPlane.setRotationFromQuaternion(
quaternion
)
sceneEntitiesManager.intersectionPlane.position.copy(
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
)
}
sceneInfra.setCallbacks({
onClick: (args) => {
if (!args) return
@ -1011,14 +1011,13 @@ export const modelingMachine = setup({
)
// Position the click raycast plane
if (sceneEntitiesManager.intersectionPlane) {
sceneEntitiesManager.intersectionPlane.setRotationFromQuaternion(
quaternion
)
sceneEntitiesManager.intersectionPlane.position.copy(
new Vector3(...(sketchDetails?.origin || [0, 0, 0]))
)
}
const dummy = new Mesh()
dummy.position.set(0, 0, 0)