Skip to content

Conversation

@parthpatelsj
Copy link
Contributor

@parthpatelsj parthpatelsj commented Nov 6, 2025

Summary

  • Add PlaneGeometry to core and React for creating and displaying planar surfaces.

Changes

  • Core: implement SpatialPlaneGeometry and CreateSpatialGeometryCommand (plane variant), add createPlaneGeometry(...) on SpatialSession, export types and factory.
  • React: expose PlaneEntity for consuming plane geometries.
  • Test server: add examples in apps/test-server/src/reality/geometry for a standard plane and a rounded plane, with spatialtap event logging. as well as box

Usage

  • Create via session.createPlaneGeometry({ width, height, ... }) and attach to a model/entity.
  • In React, use PlaneEntity and handle spatialtap via props or core addEvent.

Test

  • Tested on visionOS
Screenshot 2025-11-24 at 4 11 02 PM

@changeset-bot
Copy link

changeset-bot bot commented Nov 6, 2025

⚠️ No Changeset found

Latest commit: fdd7b10

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@parthpatelsj parthpatelsj marked this pull request as ready for review November 25, 2025 00:10
@@ -0,0 +1,163 @@
import React, { useRef, useState } from 'react'
import ReactDOM from 'react-dom/client'
import { getSession } from '@webspatial/react-sdk'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'getSession' should not be available from react-sdk. This is a legacy bug. We'll fix it soon.
It seems that you have created testcase for core-sdk part, and missing react-sdk test code

@@ -0,0 +1,2 @@
declare const __WEBSPATIAL_REACT_SDK_VERSION__: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks alreadly exist in packages/react/src/types/global.d.ts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need another globals.d.ts instead of using global.d.ts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I missed this, some reason my IDE was misconfigured.

Comment on lines +1 to +7
// Minimal ambient type so AndroidPlatform.ts compiles in non-Android envs
declare global {
interface Window {
SpatialId?: unknown // keep optional & unknown to avoid leaking shape
}
}
export {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required? Maybe it should be a separate commit it's part of the Android work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, when I try to push, it gives me an error if I don't have this:
adapter/android/AndroidPlatform.ts(57,25): error TS2339: Property 'SpatialId' does not exist on type 'Window'.

(this is unrelated to this work though, so I would agree)

},
ref,
) => {
const ctx = useRealityContext()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best to make ctx not optional

Suggested change
const ctx = useRealityContext()
const ctx = useRealityContext()!

return ent
} catch (error) {
await manager.dispose()
return null as any
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this have to be cast as any?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am following similar logic to BoxEntity, I believe it's to make tsc happy

nil
} else {
return nil
if let width = props.width, let height = props.height, let depth = props.depth {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this changes the expected behaviour. Before we expected the width, height, and depth for a BoxGeometry and would otherwise crash but now you're silently ignoring them and returning nil.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning was that we should not fail in this layer, and instead have the JS/react layer fail, and return an error. However, if this was intended behavior I can revert this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants