Skip to content

Commit

Permalink
maintenance: Update aframe-types to 0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mrxz committed May 4, 2024
1 parent c5747f3 commit 5f91d3b
Show file tree
Hide file tree
Showing 16 changed files with 79 additions and 103 deletions.
3 changes: 1 addition & 2 deletions effekseer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"@rollup/plugin-typescript": "^11.1.1",
"@types/animejs": "3.1.0",
"@types/three": "0.147.1",
"aframe-types": "0.8.22",
"aframe-typescript": "0.8.2",
"aframe-types": "0.9.1",
"concurrently": "^7.1.0",
"rimraf": "^5.0.1",
"rollup": "^2.71.1",
Expand Down
2 changes: 1 addition & 1 deletion effekseer/rollup.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default [
{
input: 'src/main.ts',
plugins: [
nodeResolve({ resolveOnly: ['aframe-typescript'] }),
nodeResolve(),
typescript({ sourceMap: true }),
],
external: ['aframe', 'effekseer'],
Expand Down
2 changes: 1 addition & 1 deletion effekseer/rollup.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default [
{
input: 'src/main.ts',
plugins: [
nodeResolve({ resolveOnly: ['aframe-typescript'] }),
nodeResolve(),
typescript({ compilerOptions: { declaration: true, declarationDir: 'typings' } }),
terser(),
],
Expand Down
18 changes: 9 additions & 9 deletions effekseer/src/effekseer.component.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import * as AFRAME from 'aframe';
import * as THREE from 'three';
import 'effekseer';
import { strict } from 'aframe-typescript';

/**
* Component for rendering an Effekseer effect.
*/
export const EffekseerComponent = AFRAME.registerComponent('effekseer', strict<{
effect: effekseer.EffekseerEffect|null,
handle: effekseer.EffekseerHandle|null,

tempMatrixArray: Float32Array,
targetLocation: THREE.Vector3,
}, 'effekseer'>().component({
export const EffekseerComponent = AFRAME.registerComponent('effekseer', {
schema: {
/** The .efk or .efkpkg file to use */
src: { type: 'asset' },
Expand All @@ -24,6 +17,13 @@ export const EffekseerComponent = AFRAME.registerComponent('effekseer', strict<{
/** Whether or not to update the effects scale, position and rotation each tick */
dynamic: { type: 'boolean', default: false },
},
__fields: {} as {
effect: effekseer.EffekseerEffect|null,
handle: effekseer.EffekseerHandle|null,

tempMatrixArray: Float32Array,
targetLocation: THREE.Vector3,
},
init: function() {
this.tempMatrixArray = new Float32Array(16);
this.targetLocation = new THREE.Vector3();
Expand Down Expand Up @@ -120,7 +120,7 @@ export const EffekseerComponent = AFRAME.registerComponent('effekseer', strict<{
remove: function() {
this.handle?.stop();
}
}));
});

declare module "aframe" {
interface Components {
Expand Down
21 changes: 11 additions & 10 deletions effekseer/src/effekseer.system.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as AFRAME from 'aframe';
import { strict } from 'aframe-typescript';
import * as THREE from 'three';
import 'effekseer';
import * as zip from '@zip.js/zip.js';
Expand All @@ -25,21 +24,23 @@ const createUnzip = async function(buffer: Uint8Array) {
/**
* System for managing the Effekseer context and handling rendering of the effects
*/
export const EffekseerSystem = AFRAME.registerSystem('effekseer', strict<{
getContext: Promise<effekseer.EffekseerContext>,
context: effekseer.EffekseerContext,
effects: Map<string, effekseer.EffekseerEffect>,

fileLoader: THREE.FileLoader,
sentinel: THREE.Mesh,
}>().system({
export const EffekseerSystem = AFRAME.registerSystem('effekseer', {
schema: {
/** URL to the effekseer.wasm file */
wasmPath: { type: "string" },
/** Frame-rate at which the effects are played back */
frameRate: { type: "number", default: 60.0 }
},

__fields: {} as {
getContext: Promise<effekseer.EffekseerContext>,
context: effekseer.EffekseerContext,
effects: Map<string, effekseer.EffekseerEffect>,

fileLoader: THREE.FileLoader,
sentinel: THREE.Mesh,
},

init: function() {
this.effects = new Map();
this.fileLoader = new THREE.FileLoader().setResponseType('arraybuffer');
Expand Down Expand Up @@ -130,7 +131,7 @@ export const EffekseerSystem = AFRAME.registerSystem('effekseer', strict<{
}
this.context.update(dt/1000.0 * this.data.frameRate);
}
}));
});

declare module "aframe" {
interface Systems {
Expand Down
3 changes: 1 addition & 2 deletions motion-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"@rollup/plugin-typescript": "^11.1.1",
"@types/animejs": "3.1.0",
"@types/three": "0.147.1",
"aframe-types": "0.8.22",
"aframe-typescript": "0.8.2",
"aframe-types": "0.9.1",
"concurrently": "^7.1.0",
"esbuild": "^0.18.17",
"rimraf": "^5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion motion-controller/rollup.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default [
{
input: 'src/main.ts',
plugins: [
nodeResolve({ resolveOnly: ['aframe-typescript', '@webxr-input-profiles/motion-controllers'] }),
nodeResolve({ resolveOnly: ['@webxr-input-profiles/motion-controllers'] }),
esbuild(),
],
external: ['aframe'],
Expand Down
24 changes: 12 additions & 12 deletions motion-controller/src/motion-controller-model.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as AFRAME from 'aframe';
import * as THREE from 'three';
import { strict } from 'aframe-typescript';
import { MotionController, VisualResponse } from '@webxr-input-profiles/motion-controllers';
import { hologramMaterialFromStandardMaterial, occluderMaterialFromStandardMaterial, phongMaterialFromStandardMaterial } from './utils';
import { HAND_JOINT_NAMES } from './hand-joint-names';
Expand All @@ -17,21 +16,22 @@ type EnhancedVisualResponse = VisualResponse & {
maxNode?: THREE.Object3D
};

const MotionControllerModelComponent = AFRAME.registerComponent('motion-controller-model', strict<{
motionControllerSystem: AFRAME.Systems['motion-controller'],
inputSourceRecord: InputSourceRecord|null,
motionController: MotionController|null,
componentMeshes: Map<string, Array<{mesh: THREE.Mesh, originalColor: THREE.Color}>>,
// Only relevant for hand tracking models
handJoints: Array<THREE.Object3D|undefined>
}>().component({
const MotionControllerModelComponent = AFRAME.registerComponent('motion-controller-model', {
schema: {
hand: { type: 'string', oneOf: ['left', 'right'], default: 'left' },
overrideMaterial: { type: 'string', oneOf: ['none', 'phong', 'occluder'], default: 'phong'},
overrideHandMaterial: { type: 'string', oneOf: ['none', 'phong', 'occluder', 'hologram'], default: 'hologram'},
buttonTouchColor: { type: 'color', default: '#8AB' },
buttonPressColor: { type: 'color', default: '#2DF' }
},
__fields: {} as {
motionControllerSystem: AFRAME.Systems['motion-controller'],
inputSourceRecord: InputSourceRecord|null,
motionController: MotionController|null,
componentMeshes: Map<string, Array<{mesh: THREE.Mesh, originalColor: THREE.Color}>>,
// Only relevant for hand tracking models
handJoints: Array<THREE.Object3D|undefined>
},
init: function() {
this.motionControllerSystem = this.el.sceneEl.systems['motion-controller'];
this.componentMeshes = new Map();
Expand All @@ -47,7 +47,7 @@ const MotionControllerModelComponent = AFRAME.registerComponent('motion-controll
return;
}
this.el.setObject3D('mesh', gltf.scene);
const isHandModel = this.motionController.id === 'generic-hand';
const isHandModel = this.motionController?.id === 'generic-hand';

// Traverse the mesh to change materials and extract references to hand joints
gltf.scene.traverse(child => {
Expand Down Expand Up @@ -87,7 +87,7 @@ const MotionControllerModelComponent = AFRAME.registerComponent('motion-controll
});

this.componentMeshes.clear();
Object.values(this.motionController.components).forEach((component) => {
Object.values(this.motionController!.components).forEach((component) => {
// Can't traverse the rootNodes of the components, as these are hardly ever correct.
// See: https://github.com/immersive-web/webxr-input-profiles/issues/249
const componentMeshes: Array<{mesh: THREE.Mesh, originalColor: THREE.Color}> = [];
Expand Down Expand Up @@ -203,7 +203,7 @@ const MotionControllerModelComponent = AFRAME.registerComponent('motion-controll
});
}
}
}));
});

declare module "aframe" {
export interface Components {
Expand Down
12 changes: 6 additions & 6 deletions motion-controller/src/motion-controller-space.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as AFRAME from 'aframe';
import { strict } from 'aframe-typescript';

const MotionControllerSpaceComponent = AFRAME.registerComponent('motion-controller-space', strict<{
motionControllerSystem: AFRAME.Systems['motion-controller'],
inputSource: XRInputSource|undefined,
}>().component({
const MotionControllerSpaceComponent = AFRAME.registerComponent('motion-controller-space', {
schema: {
hand: { type: 'string', oneOf: ['left', 'right'], default: 'left' },
space: { type: 'string', oneOf: ['gripSpace', 'targetRaySpace'], default: 'targetRaySpace' },
},
__fields: {} as {
motionControllerSystem: AFRAME.Systems['motion-controller'],
inputSource: XRInputSource|undefined,
},
init: function() {
this.motionControllerSystem = this.el.sceneEl.systems['motion-controller'];
this.el.sceneEl.addEventListener('motion-controller-change', _event => {
Expand All @@ -35,7 +35,7 @@ const MotionControllerSpaceComponent = AFRAME.registerComponent('motion-controll
this.el.object3D.matrix.decompose(this.el.object3D.position, this.el.object3D.quaternion, this.el.object3D.scale);
}
}
}));
});

declare module "aframe" {
export interface Components {
Expand Down
24 changes: 12 additions & 12 deletions motion-controller/src/motion-controller.system.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as AFRAME from 'aframe';
import { SceneEvent } from 'aframe';
import { strict } from 'aframe-typescript';
import { Component, fetchProfile, MotionController } from '@webxr-input-profiles/motion-controllers';

const DEFAULT_INPUT_PROFILE_ASSETS_URI = 'https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets/dist/profiles';
Expand All @@ -13,16 +12,7 @@ export interface InputSourceRecord {
jointState?: {poses: Float32Array, radii: Float32Array},
};

const MotionControllerSystem = AFRAME.registerSystem('motion-controller', strict<{
/* Currently active XR session */
xrSession: XRSession|null;
/* List of active input sources */
inputSources: Array<InputSourceRecord>

/* Dedicated slots for left/right hand for convenience */
left: InputSourceRecord|null,
right: InputSourceRecord|null,
}>().system({
const MotionControllerSystem = AFRAME.registerSystem('motion-controller', {
schema: {
/** Base URI for fetching profiles and controller models */
profilesUri: { type: 'string', default: DEFAULT_INPUT_PROFILE_ASSETS_URI },
Expand All @@ -31,6 +21,16 @@ const MotionControllerSystem = AFRAME.registerSystem('motion-controller', strict
/** Whether or not input sources representing hands should be reported or not */
enableHands: { type: 'boolean', default: true },
},
__fields: {} as {
/* Currently active XR session */
xrSession: XRSession|null;
/* List of active input sources */
inputSources: Array<InputSourceRecord>

/* Dedicated slots for left/right hand for convenience */
left: InputSourceRecord|null,
right: InputSourceRecord|null,
},
init: function() {
this.inputSources = [];
this.left = null;
Expand Down Expand Up @@ -188,7 +188,7 @@ const MotionControllerSystem = AFRAME.registerSystem('motion-controller', strict
// FIXME: Perhaps only fetch radii once or upon request(?)
(xrFrame as any).fillJointRadii(hand.values(), inputSourceRecord.jointState!.radii);
}
}));
});

export interface ButtonEventDetails {
inputSource: XRInputSource;
Expand Down
2 changes: 1 addition & 1 deletion motion-controller/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"declaration": false,
"rootDir": "src",
"paths": {
"aframe": ["./node_modules/aframe-types"]
"aframe": ["../node_modules/aframe-types"]
}
},
"include": ["src"],
Expand Down
2 changes: 1 addition & 1 deletion screen-fade/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@compodoc/live-server": "1.2.3",
"@types/animejs": "3.1.0",
"@types/three": "0.147.1",
"aframe-types": "0.8.14",
"aframe-types": "0.9.1",
"concurrently": "^7.1.0",
"rollup": "^2.71.1",
"rollup-plugin-terser": "^7.0.2",
Expand Down
12 changes: 6 additions & 6 deletions screen-fade/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ __metadata:
"@compodoc/live-server": "npm:1.2.3"
"@types/animejs": "npm:3.1.0"
"@types/three": "npm:0.147.1"
aframe-types: "npm:0.8.14"
aframe-types: "npm:0.9.1"
concurrently: "npm:^7.1.0"
rollup: "npm:^2.71.1"
rollup-plugin-terser: "npm:^7.0.2"
Expand Down Expand Up @@ -213,13 +213,13 @@ __metadata:
languageName: node
linkType: hard

"aframe-types@npm:0.8.14":
version: 0.8.14
resolution: "aframe-types@npm:0.8.14"
"aframe-types@npm:0.9.1":
version: 0.9.1
resolution: "aframe-types@npm:0.9.1"
peerDependencies:
"@types/animejs": 3.1.0
"@types/three": 0.147.1
checksum: 10/a43d5fd9cee436fe5e50b89994bf6fcef32ad41a091cdbc5fdc842825c5421d790108a568f07c32234bef236c6f43f149bffcc07e7ba6833700b3c1cce98559d
"@types/three": 0.164.0
checksum: 10/c671f56599c34e0f4daa8123a90429d3df3812acfbd6df0350adde1cf7c0901432a49bae718043193df4db3718865cea3b8da287bfd2a19f9375af83d056d4cd
languageName: node
linkType: hard

Expand Down
2 changes: 1 addition & 1 deletion sky-background/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@compodoc/live-server": "1.2.3",
"@types/animejs": "3.1.0",
"@types/three": "0.147.1",
"aframe-types": "0.8.22",
"aframe-types": "0.9.1",
"concurrently": "^7.1.0",
"rollup": "^2.71.1",
"rollup-plugin-terser": "^7.0.2",
Expand Down
12 changes: 6 additions & 6 deletions sky-background/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ __metadata:
"@compodoc/live-server": "npm:1.2.3"
"@types/animejs": "npm:3.1.0"
"@types/three": "npm:0.147.1"
aframe-types: "npm:0.8.22"
aframe-types: "npm:0.9.1"
concurrently: "npm:^7.1.0"
rollup: "npm:^2.71.1"
rollup-plugin-terser: "npm:^7.0.2"
Expand Down Expand Up @@ -213,13 +213,13 @@ __metadata:
languageName: node
linkType: hard

"aframe-types@npm:0.8.22":
version: 0.8.22
resolution: "aframe-types@npm:0.8.22"
"aframe-types@npm:0.9.1":
version: 0.9.1
resolution: "aframe-types@npm:0.9.1"
peerDependencies:
"@types/animejs": 3.1.0
"@types/three": 0.147.1
checksum: 10/ecf7cd1f14af89dc84450281e1544a9fbf75222cf810c407fbdf3b0cfd3ada82b65a9c13040f5f9f91d0767c2d309eb4c535b7853257c0158a238d27f14b857e
"@types/three": 0.164.0
checksum: 10/c671f56599c34e0f4daa8123a90429d3df3812acfbd6df0350adde1cf7c0901432a49bae718043193df4db3718865cea3b8da287bfd2a19f9375af83d056d4cd
languageName: node
linkType: hard

Expand Down
Loading

0 comments on commit 5f91d3b

Please sign in to comment.