@opsydyn/effect-three 0.4.0 → 0.6.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +4 -2
  3. package/dist/{index-h3vf50fn.js → index-re3rrfwd.js} +880 -79
  4. package/dist/index-re3rrfwd.js.map +56 -0
  5. package/dist/index.js +71 -2
  6. package/dist/index.js.map +3 -3
  7. package/dist/kernel/bodies.d.ts +20 -1
  8. package/dist/kernel/bodies.d.ts.map +1 -1
  9. package/dist/kernel/build.d.ts +24 -2
  10. package/dist/kernel/build.d.ts.map +1 -1
  11. package/dist/kernel/description.d.ts +68 -0
  12. package/dist/kernel/description.d.ts.map +1 -1
  13. package/dist/kernel/equality.d.ts +3 -1
  14. package/dist/kernel/equality.d.ts.map +1 -1
  15. package/dist/kernel/index.d.ts +7 -5
  16. package/dist/kernel/index.d.ts.map +1 -1
  17. package/dist/kernel/index.js +20 -2
  18. package/dist/kernel/index.js.map +1 -1
  19. package/dist/kernel/loop.d.ts.map +1 -1
  20. package/dist/kernel/paintOrder.d.ts +53 -0
  21. package/dist/kernel/paintOrder.d.ts.map +1 -0
  22. package/dist/kernel/physics.d.ts +39 -0
  23. package/dist/kernel/physics.d.ts.map +1 -1
  24. package/dist/kernel/pointer.d.ts +19 -1
  25. package/dist/kernel/pointer.d.ts.map +1 -1
  26. package/dist/kernel/preview.d.ts +32 -0
  27. package/dist/kernel/preview.d.ts.map +1 -0
  28. package/dist/kernel/sceneGraph.d.ts +3 -1
  29. package/dist/kernel/sceneGraph.d.ts.map +1 -1
  30. package/dist/kernel/sceneIndex.d.ts +5 -0
  31. package/dist/kernel/sceneIndex.d.ts.map +1 -1
  32. package/dist/kernel/timeline.d.ts +60 -0
  33. package/dist/kernel/timeline.d.ts.map +1 -0
  34. package/dist/runtime/SceneFile.d.ts +14 -0
  35. package/dist/runtime/SceneFile.d.ts.map +1 -1
  36. package/dist/runtime/SceneSchema.d.ts +86 -0
  37. package/dist/runtime/SceneSchema.d.ts.map +1 -1
  38. package/package.json +3 -2
  39. package/src/kernel/bodies.ts +299 -17
  40. package/src/kernel/build.ts +42 -1
  41. package/src/kernel/description.ts +68 -0
  42. package/src/kernel/equality.ts +22 -0
  43. package/src/kernel/index.ts +13 -1
  44. package/src/kernel/loop.ts +2 -0
  45. package/src/kernel/paintOrder.ts +274 -0
  46. package/src/kernel/physics.ts +86 -1
  47. package/src/kernel/pointer.ts +43 -5
  48. package/src/kernel/preview.ts +467 -0
  49. package/src/kernel/sceneGraph.ts +35 -3
  50. package/src/kernel/sceneIndex.ts +8 -0
  51. package/src/kernel/timeline.ts +93 -0
  52. package/src/runtime/SceneSchema.ts +72 -0
  53. package/dist/index-h3vf50fn.js.map +0 -53
@@ -405,11 +405,19 @@ export const Joint = Schema.Struct({
405
405
  contacts: Schema.Boolean,
406
406
  });
407
407
 
408
+ /** A count of physics steps. */
409
+ const StepCount = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
410
+
408
411
  export const Physics = Schema.Struct({
409
412
  gravity: Vec3,
410
413
  paused: Schema.Boolean,
411
414
  timeStep: Positive,
412
415
  interpolate: Schema.Boolean,
416
+ until: absentAsNull(StepCount),
417
+ run: Schema.Int.pipe(Schema.withDecodingDefaultKey(Effect.succeed(0))),
418
+ snapshotAt: absentAsNull(StepCount),
419
+ from: absentAsNull(Schema.Struct({ step: StepCount, snapshot: Schema.NullOr(Schema.String) })),
420
+ keep: StepCount.pipe(Schema.withDecodingDefaultKey(Effect.succeed(0))),
413
421
  debug: Schema.Boolean,
414
422
  joints: Schema.Array(Joint),
415
423
  });
@@ -912,6 +920,17 @@ export const Xr = Schema.Struct({
912
920
  /** Whether the scene claims the pointer's gestures from the page. */
913
921
  export const Gestures = Schema.Literals(['page', 'scene']);
914
922
 
923
+ /** What an asset is: a glTF or GLB model, a colour texture, an HDR panorama, a typeface font. */
924
+ export const AssetKind = Schema.Literals(['model', 'texture', 'environment', 'font']);
925
+
926
+ /** An asset a scene asks for (`modelAsset` and the rest). */
927
+ export const Asset = Schema.Struct({
928
+ kind: AssetKind,
929
+ id: Schema.String,
930
+ url: Schema.String,
931
+ levels: Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
932
+ });
933
+
915
934
  export const SceneDescription = Schema.Struct({
916
935
  camera: Camera,
917
936
  gestures: Gestures,
@@ -925,11 +944,42 @@ export const SceneDescription = Schema.Struct({
925
944
  physics: Schema.NullOr(Physics),
926
945
  xr: Schema.NullOr(Xr),
927
946
  measure: Schema.Array(Schema.String),
947
+ assets: Schema.Array(Asset).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
928
948
  render: RenderSettings,
929
949
  resources: ResourceDefinitions,
930
950
  children: Schema.Array(SceneNode),
931
951
  });
932
952
 
953
+ /**
954
+ * Detail of asset loaded events: the asset, the level of detail now shown (0 for the
955
+ * coarsest of its `levels`, as many as it has levels for `url` itself) and whether that is
956
+ * the finest, and for a model its parts and clips.
957
+ */
958
+ export const AssetLoadedDetail = Schema.Struct({
959
+ kind: AssetKind,
960
+ id: Schema.String,
961
+ url: Schema.String,
962
+ levels: Schema.Array(Schema.String),
963
+ level: Schema.Int,
964
+ final: Schema.Boolean,
965
+ /** Names of the objects inside a model, as hits report them in `part`. */
966
+ parts: Schema.Array(Schema.String),
967
+ /** Names of a model's animation clips. */
968
+ clips: Schema.Array(Schema.String),
969
+ });
970
+
971
+ /**
972
+ * Detail of asset failed events: the asset, and why its finest level could not be loaded
973
+ * (a coarser level shown before stays).
974
+ */
975
+ export const AssetFailedDetail = Schema.Struct({
976
+ kind: AssetKind,
977
+ id: Schema.String,
978
+ url: Schema.String,
979
+ levels: Schema.Array(Schema.String),
980
+ reason: Schema.String,
981
+ });
982
+
933
983
  /** Detail of pointer-leave events: the interactive mesh's key. */
934
984
  export const KeyDetail = Schema.Struct({ key: Schema.String });
935
985
 
@@ -1030,6 +1080,17 @@ export const CollisionDetail = Schema.Struct({
1030
1080
  started: Schema.Boolean,
1031
1081
  });
1032
1082
 
1083
+ /**
1084
+ * Detail of physics reached events: the run and step a world on `physics({ until })`
1085
+ * reached, a checksum of its bodies' poses there, and at `snapshotAt` a snapshot of it.
1086
+ */
1087
+ export const PhysicsReachedDetail = Schema.Struct({
1088
+ run: Schema.Int,
1089
+ step: StepCount,
1090
+ checksum: Schema.String,
1091
+ snapshot: Schema.optionalKey(Schema.String),
1092
+ });
1093
+
1033
1094
  const XrHand = Schema.Literals(['left', 'right', 'none']);
1034
1095
 
1035
1096
  /** Detail of XR stick events: a thumbstick pushed past halfway, or let back. */
@@ -1139,6 +1200,7 @@ export const SceneEvent = Schema.Union([
1139
1200
  Schema.TaggedStruct('Measured', MeasuredDetail.fields),
1140
1201
  Schema.TaggedStruct('LabelMeasured', LabelMeasuredDetail.fields),
1141
1202
  Schema.TaggedStruct('ContactForce', ContactForceDetail.fields),
1203
+ Schema.TaggedStruct('PhysicsReached', PhysicsReachedDetail.fields),
1142
1204
  Schema.TaggedStruct('XrStick', XrStickDetail.fields),
1143
1205
  Schema.TaggedStruct('XrButton', XrButtonDetail.fields),
1144
1206
  Schema.TaggedStruct('XrSurface', XrSurfaceDetail.fields),
@@ -1164,6 +1226,7 @@ export const DescriptionError = Schema.Union([
1164
1226
  Schema.TaggedStruct('UnknownOverlayNode', { key: Schema.String, node: Schema.String }),
1165
1227
  Schema.TaggedStruct('UnknownOverlayView', { key: Schema.String, view: Schema.String }),
1166
1228
  Schema.TaggedStruct('UnknownMeasuredNode', { key: Schema.String }),
1229
+ Schema.TaggedStruct('DuplicateAssetId', { id: Schema.String }),
1167
1230
  Schema.TaggedStruct('DuplicateJointKey', { key: Schema.String }),
1168
1231
  Schema.TaggedStruct('UnknownJointBody', { joint: Schema.String, body: Schema.String }),
1169
1232
  Schema.TaggedStruct('DuplicateRenderTextureId', { id: Schema.String }),
@@ -1247,6 +1310,15 @@ export const Lockstep = <S extends Schema.Top>(input: S) =>
1247
1310
  received: Schema.Array(LockstepPacket(input)),
1248
1311
  });
1249
1312
 
1313
+ /** A timeline of physics steps (`Timeline.make`) over the app's `input`s, for a Model. */
1314
+ export const Timeline = <S extends Schema.Top>(input: S) =>
1315
+ Schema.Struct({
1316
+ inputs: Schema.Array(Schema.Struct({ step: StepCount, input })),
1317
+ applied: Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)),
1318
+ reached: Schema.NullOr(StepCount),
1319
+ frontier: StepCount,
1320
+ });
1321
+
1250
1322
  /** A measuring tape as data (`tape`), for a Model that keeps it. */
1251
1323
  export const Tape = Schema.Struct({
1252
1324
  from: Schema.NullOr(Vec3),