Skip to content

Commit 4c8a285

Browse files
Peter Wangmeta-codesync[bot]
authored andcommitted
PathByFilePicker
Summary: When glxf is {"keyString":"src","type":"string","value":"./audio/violin.ogg"}, how does it parse? It calls mapGLXFDataToProps which simply does props["src"] = fieldData.value → props["src"] = "./audio/violin.ogg". The "type":"string" is ignored. How to make it support {"keyString":"src","type":"PathByFilePicker","value":"./audio/violin.ogg"} as a string? It already works. Looking at the actual GLXF file at Composition.glxf , this is exactly what's already being produced and parsed: "src": { "keyString": "src", "type": "PathByFilePicker", "value": "./audio/violin.ogg" } The runtime parser extracts "./audio/violin.ogg" as a string value from fieldData.value — the "type": "PathByFilePicker" is treated identically to "type": "String" because the runtime code never checks the GLXF type field (except for Enum, where it checks the component schema type, not the GLXF type). Reviewed By: felixtrz Differential Revision: D93434772 fbshipit-source-id: bb76704c43d8891ed4690a405e92c0593f4b67bd
1 parent 47742e8 commit 4c8a285

File tree

6 files changed

+23
-12
lines changed

6 files changed

+23
-12
lines changed

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@pmndrs/uikit": "^1.0.60",
4141
"@pmndrs/uikitml": "^0.1.12",
4242
"@preact/signals-core": "^1.11.0",
43-
"elics": "^3.3.0",
43+
"elics": "^3.4.1",
4444
"three": "*",
4545
"three-mesh-bvh": "^0.9.1"
4646
},

packages/core/src/audio/audio.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export const DistanceModel = {
5757
export const AudioSource = createComponent(
5858
'AudioSource',
5959
{
60-
// Core properties
61-
src: { type: Types.String, default: '' }, // URL or cache key for an audio buffer
60+
// Core properties PathByFilePickerAttribute
61+
src: { type: Types.FilePath, default: '' }, // URL or cache key for an audio buffer
6262
volume: { type: Types.Float32, default: 1.0 }, // Linear gain [0..1]
6363
loop: { type: Types.Boolean, default: false }, // When true, newly created instances loop
6464
autoplay: { type: Types.Boolean, default: false }, // Trigger a single play on first update after load

packages/starter-assets/starter-template/metaspatial-ar/components/IWSDKAudioSource.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
<EnumValue value="furthest"/>
1717
</Enum>
1818
<Component name="AudioSource" description="AudioSource playback component for positional and non-positional sounds">
19-
<StringAttribute name="src" defaultValue=""/>
19+
<PathByFilePickerAttribute
20+
name="src"
21+
defaultValue=""
22+
fileTypes=".mp3,.wav,.ogg,.m4a,.aac"
23+
description="Select an audio file to be used in your project. Files will be automatically copied to your project. The value is the relative path of the file within the final IWSDK/Spatial SDK package."
24+
/>
2025
<FloatAttribute name="volume" defaultValue="1f"/>
2126
<BooleanAttribute name="loop" defaultValue="false"/>
2227
<BooleanAttribute name="autoplay" defaultValue="false"/>
@@ -33,4 +38,4 @@
3338
<FloatAttribute name="crossfadeDuration" defaultValue="0.1f"/>
3439
<EnumAttribute name="instanceStealPolicy" defaultValue="InstanceStealPolicy.oldest"/>
3540
</Component>
36-
</ComponentSchema>
41+
</ComponentSchema>

packages/starter-assets/starter-template/metaspatial-vr/components/IWSDKAudioSource.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
<EnumValue value="furthest"/>
1717
</Enum>
1818
<Component name="AudioSource" description="AudioSource playback component for positional and non-positional sounds">
19-
<StringAttribute name="src" defaultValue=""/>
19+
<PathByFilePickerAttribute
20+
name="src"
21+
defaultValue=""
22+
fileTypes=".mp3,.wav,.ogg,.m4a,.aac"
23+
description="Select an audio file to be used in your project. Files will be automatically copied to your project. The value is the relative path of the file within the final IWSDK/Spatial SDK package."
24+
/>
2025
<FloatAttribute name="volume" defaultValue="1f"/>
2126
<BooleanAttribute name="loop" defaultValue="false"/>
2227
<BooleanAttribute name="autoplay" defaultValue="false"/>
@@ -33,4 +38,4 @@
3338
<FloatAttribute name="crossfadeDuration" defaultValue="0.1f"/>
3439
<EnumAttribute name="instanceStealPolicy" defaultValue="InstanceStealPolicy.oldest"/>
3540
</Component>
36-
</ComponentSchema>
41+
</ComponentSchema>

packages/vite-plugin-metaspatial/src/discover-components/xml-generator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ function mapTypeToXMLAttribute(elicsType?: string): string {
269269
Int64: 'LongAttribute',
270270
Boolean: 'BooleanAttribute',
271271
String: 'StringAttribute',
272+
FilePath: 'PathByFilePickerAttribute',
272273
Vec2: 'Vector2Attribute',
273274
Vec3: 'Vector3Attribute',
274275
Vec4: 'Vector4Attribute',

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)