@ -48,8 +48,6 @@ const commonPoints = {
|
||||
startAt: '[7.19, -9.7]',
|
||||
num1: 7.25,
|
||||
num2: 14.44,
|
||||
// num1: 9.64,
|
||||
// num2: 19.19,
|
||||
}
|
||||
|
||||
test.afterEach(async ({ context, page }, testInfo) => {
|
||||
@ -141,8 +139,9 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
|
||||
await expect(u.codeLocator)
|
||||
.toHaveText(`const sketch001 = startSketchOn('XZ')
|
||||
|> startProfileAt(${commonPoints.startAt}, %)`)
|
||||
}
|
||||
} else {
|
||||
await page.waitForTimeout(500)
|
||||
}
|
||||
|
||||
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 10)
|
||||
await page.waitForTimeout(500)
|
||||
@ -152,8 +151,9 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
|
||||
.toHaveText(`const sketch001 = startSketchOn('XZ')
|
||||
|> startProfileAt(${commonPoints.startAt}, %)
|
||||
|> line([${commonPoints.num1}, 0], %)`)
|
||||
}
|
||||
} else {
|
||||
await page.waitForTimeout(500)
|
||||
}
|
||||
|
||||
await page.mouse.click(startXPx + PUR * 20, 500 - PUR * 20)
|
||||
if (openPanes.includes('code')) {
|
||||
@ -162,8 +162,9 @@ async function doBasicSketch(page: Page, openPanes: string[]) {
|
||||
|> startProfileAt(${commonPoints.startAt}, %)
|
||||
|> line([${commonPoints.num1}, 0], %)
|
||||
|> line([0, ${commonPoints.num1 + 0.01}], %)`)
|
||||
}
|
||||
} else {
|
||||
await page.waitForTimeout(500)
|
||||
}
|
||||
await page.mouse.click(startXPx, 500 - PUR * 20)
|
||||
if (openPanes.includes('code')) {
|
||||
await expect(u.codeLocator)
|
||||
|
@ -585,10 +585,6 @@ export class CameraControls {
|
||||
.add(direction.multiplyScalar(-distanceAfter))
|
||||
this.camera.position.copy(newPosition)
|
||||
|
||||
const { z_near, z_far } = calculateNearFarFromFOV(this.lastPerspectiveFov)
|
||||
this.camera.near = z_near
|
||||
this.camera.far = z_far
|
||||
|
||||
if (splitEngineCalls) {
|
||||
await this.engineCommandManager.sendSceneCommand({
|
||||
type: 'modeling_cmd_req',
|
||||
@ -1144,9 +1140,6 @@ function convertThreeCamValuesToEngineCam({
|
||||
up: Vector3
|
||||
vantage: Vector3
|
||||
} {
|
||||
// Something to consider is that the orbit controls have a target,
|
||||
// we're kind of deriving the target/lookAtVector here when it might not be needed
|
||||
// leaving for now since it's working but maybe revisit later
|
||||
const euler = new Euler().setFromQuaternion(quaternion, 'XYZ')
|
||||
|
||||
const upVector = new Vector3(0, 1, 0).applyEuler(euler).normalize()
|
||||
@ -1157,18 +1150,50 @@ function convertThreeCamValuesToEngineCam({
|
||||
vantage: position,
|
||||
}
|
||||
}
|
||||
const lookAtVector = new Vector3(0, 0, -1)
|
||||
.applyEuler(euler)
|
||||
.normalize()
|
||||
.add(position)
|
||||
const fudgeFactor2 = zoom * 0.9979224466814468 - 0.03473692325839295
|
||||
const zoomFactor = (-ZOOM_MAGIC_NUMBER + fudgeFactor2) / zoom
|
||||
const direction = lookAtVector.clone().sub(position).normalize()
|
||||
const newVantage = position.clone().add(direction.multiplyScalar(zoomFactor))
|
||||
|
||||
// re-implementing stuff here, though this is a bunch of Mike's code
|
||||
// if we need to pull him in again, at least it will be familiar to him
|
||||
// and it's all simple functions.
|
||||
interface Coord3d {
|
||||
x: number
|
||||
y: number
|
||||
z: number
|
||||
}
|
||||
|
||||
function buildLookAt(distance: number, center: Coord3d, eye: Coord3d) {
|
||||
const eyeVector = normalized(sub(eye, center))
|
||||
return { center: center, eye: add(center, mult(eyeVector, distance)) }
|
||||
}
|
||||
|
||||
function mult(vecA: Coord3d, sc: number): Coord3d {
|
||||
return { x: vecA.x * sc, y: vecA.y * sc, z: vecA.z * sc }
|
||||
}
|
||||
|
||||
function add(vecA: Coord3d, vecB: Coord3d): Coord3d {
|
||||
return { x: vecA.x + vecB.x, y: vecA.y + vecB.y, z: vecA.z + vecB.z }
|
||||
}
|
||||
|
||||
function sub(vecA: Coord3d, vecB: Coord3d): Coord3d {
|
||||
return { x: vecA.x - vecB.x, y: vecA.y - vecB.y, z: vecA.z - vecB.z }
|
||||
}
|
||||
|
||||
function dot(vecA: Coord3d, vecB: Coord3d) {
|
||||
return vecA.x * vecB.x + vecA.y * vecB.y + vecA.z * vecB.z
|
||||
}
|
||||
|
||||
function length(vecA: Coord3d) {
|
||||
return Math.sqrt(dot(vecA, vecA))
|
||||
}
|
||||
|
||||
function normalized(vecA: Coord3d) {
|
||||
return mult(vecA, 1.0 / length(vecA))
|
||||
}
|
||||
|
||||
const lookAt = buildLookAt(64 / zoom, target, position)
|
||||
return {
|
||||
center: lookAtVector,
|
||||
up: upVector,
|
||||
vantage: newVantage,
|
||||
center: new Vector3(lookAt.center.x, lookAt.center.y, lookAt.center.z),
|
||||
up: new Vector3(0, 0, 1),
|
||||
vantage: new Vector3(lookAt.eye.x, lookAt.eye.y, lookAt.eye.z),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1224,7 +1249,7 @@ export async function letEngineAnimateAndSyncCamAfter(
|
||||
type: 'enable_sketch_mode',
|
||||
adjust_camera: true,
|
||||
animated: !isReducedMotion(),
|
||||
ortho: false,
|
||||
ortho: true,
|
||||
entity_id: entityId,
|
||||
},
|
||||
})
|
||||
@ -1241,25 +1266,4 @@ export async function letEngineAnimateAndSyncCamAfter(
|
||||
type: 'default_camera_get_settings',
|
||||
},
|
||||
})
|
||||
await engineCommandManager.sendSceneCommand({
|
||||
type: 'modeling_cmd_req',
|
||||
cmd_id: uuidv4(),
|
||||
cmd: {
|
||||
type: 'enable_sketch_mode',
|
||||
adjust_camera: true,
|
||||
animated: false,
|
||||
ortho: true,
|
||||
entity_id: entityId,
|
||||
},
|
||||
})
|
||||
await new Promise((resolve) => setTimeout(resolve, 50))
|
||||
await engineCommandManager.sendSceneCommand({
|
||||
// CameraControls subscribes to default_camera_get_settings response events
|
||||
// firing this at connection ensure the camera's are synced initially
|
||||
type: 'modeling_cmd_req',
|
||||
cmd_id: uuidv4(),
|
||||
cmd: {
|
||||
type: 'default_camera_get_settings',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -68,11 +68,11 @@ import { EditorSelection, Transaction } from '@codemirror/state'
|
||||
import { useSearchParams } from 'react-router-dom'
|
||||
import { letEngineAnimateAndSyncCamAfter } from 'clientSideScene/CameraControls'
|
||||
import { getVarNameModal } from 'hooks/useToolbarGuards'
|
||||
import { uuidv4 } from 'lib/utils'
|
||||
import { err, trap } from 'lib/trap'
|
||||
import { useCommandsContext } from 'hooks/useCommandsContext'
|
||||
import { modelingMachineEvent } from 'editor/manager'
|
||||
import { hasValidFilletSelection } from 'lang/modifyAst/addFillet'
|
||||
import { uuidv4 } from 'lib/utils'
|
||||
|
||||
type MachineContext<T extends AnyStateMachine> = {
|
||||
state: StateFrom<T>
|
||||
@ -133,47 +133,12 @@ export const ModelingMachineProvider = ({
|
||||
;(async () => {
|
||||
// blocks entering a sketch until after exit sketch code has run
|
||||
kclManager.isExecuting = true
|
||||
sceneInfra.camControls.syncDirection = 'clientToEngine'
|
||||
|
||||
await sceneInfra.camControls.snapToPerspectiveBeforeHandingBackControlToEngine()
|
||||
|
||||
sceneInfra.camControls.syncDirection = 'engineToClient'
|
||||
|
||||
const resp = await engineCommandManager.sendSceneCommand({
|
||||
type: 'modeling_cmd_req',
|
||||
cmd_id: uuidv4(),
|
||||
cmd: {
|
||||
type: 'default_camera_get_settings',
|
||||
},
|
||||
})
|
||||
|
||||
const settings =
|
||||
resp &&
|
||||
resp.success &&
|
||||
resp.resp.type === 'modeling' &&
|
||||
resp.resp.data.modeling_response.type ===
|
||||
'default_camera_get_settings'
|
||||
? resp.resp.data.modeling_response.data.settings
|
||||
: ({} as Models['DefaultCameraGetSettings_type']['settings'])
|
||||
|
||||
if (settings.up.z !== 1) {
|
||||
// workaround for gimbal lock situation
|
||||
await engineCommandManager.sendSceneCommand({
|
||||
type: 'modeling_cmd_req',
|
||||
cmd_id: uuidv4(),
|
||||
cmd: {
|
||||
type: 'default_camera_look_at',
|
||||
center: settings.center,
|
||||
vantage: {
|
||||
...settings.pos,
|
||||
y:
|
||||
settings.pos.y +
|
||||
(settings.center.z - settings.pos.z > 0 ? 2 : -2),
|
||||
},
|
||||
up: { x: 0, y: 0, z: 1 },
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
store.videoElement?.pause()
|
||||
kclManager.executeCode().then(() => {
|
||||
if (engineCommandManager.engineConnection?.idleMode) return
|
||||
|
@ -29,7 +29,7 @@ export default function Tooltip({
|
||||
return (
|
||||
<div
|
||||
// @ts-ignore while awaiting merge of this PR for support of "inert" https://github.com/DefinitelyTyped/DefinitelyTyped/pull/60822
|
||||
inert={inert}
|
||||
inert={`${inert}`}
|
||||
role="tooltip"
|
||||
className={`p-3 ${
|
||||
position !== 'left' && position !== 'right' ? 'px-0' : ''
|
||||
|
Reference in New Issue
Block a user