Skip to content

Commit

Permalink
refactor: try moving several utility implementations to a new package…
Browse files Browse the repository at this point in the history
… `@pixiv/three-vrm-utils`
  • Loading branch information
0b5vr committed Jan 6, 2023
1 parent 61a7c89 commit 304b70d
Show file tree
Hide file tree
Showing 42 changed files with 405 additions and 268 deletions.
1 change: 1 addition & 0 deletions packages/three-vrm-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
]
},
"dependencies": {
"@pixiv/three-vrm-utils": "1.0.6",
"@pixiv/types-vrm-0.0": "1.0.0",
"@pixiv/types-vrmc-vrm-1.0": "1.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { VRMExpressionPresetName } from './VRMExpressionPresetName';
import { saturate } from '../utils/saturate';
import { saturate } from '@pixiv/three-vrm-utils';
import type { VRMExpression } from './VRMExpression';

export class VRMExpressionManager {
Expand Down
2 changes: 1 addition & 1 deletion packages/three-vrm-core/src/humanoid/VRMRig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as THREE from 'three';
import { quatInvertCompat } from '../utils/quatInvertCompat';
import { quatInvertCompat } from '@pixiv/three-vrm-utils';
import type { VRMHumanBone } from './VRMHumanBone';
import type { VRMHumanBones } from './VRMHumanBones';
import type { VRMHumanBoneName } from './VRMHumanBoneName';
Expand Down
3 changes: 1 addition & 2 deletions packages/three-vrm-core/src/lookAt/VRMLookAt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as THREE from 'three';
import { VRMHumanoid } from '../humanoid';
import { getWorldQuaternionLite } from '../utils/getWorldQuaternionLite';
import { quatInvertCompat } from '../utils/quatInvertCompat';
import { getWorldQuaternionLite, quatInvertCompat } from '@pixiv/three-vrm-utils';
import { calcAzimuthAltitude } from './utils/calcAzimuthAltitude';
import type { VRMLookAtApplier } from './VRMLookAtApplier';
import { sanitizeAngle } from './utils/sanitizeAngle';
Expand Down
2 changes: 1 addition & 1 deletion packages/three-vrm-core/src/lookAt/VRMLookAtBoneApplier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as THREE from 'three';
import type { VRMLookAtApplier } from './VRMLookAtApplier';
import { VRMLookAtRangeMap } from './VRMLookAtRangeMap';
import { calcAzimuthAltitude } from './utils/calcAzimuthAltitude';
import { getWorldQuaternionLite } from '../utils/getWorldQuaternionLite';
import { getWorldQuaternionLite } from '@pixiv/three-vrm-utils';

const VEC3_POSITIVE_Z = new THREE.Vector3(0.0, 0.0, 1.0);

Expand Down
2 changes: 1 addition & 1 deletion packages/three-vrm-core/src/lookAt/VRMLookAtRangeMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { saturate } from '../utils/saturate';
import { saturate } from '@pixiv/three-vrm-utils';

export class VRMLookAtRangeMap {
/**
Expand Down
1 change: 1 addition & 0 deletions packages/three-vrm-node-constraint/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
]
},
"dependencies": {
"@pixiv/three-vrm-utils": "1.0.6",
"@pixiv/types-vrmc-node-constraint-1.0": "1.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/three-vrm-node-constraint/src/VRMAimConstraint.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as THREE from 'three';
import { decomposePosition } from './utils/decomposePosition';
import { decomposeRotation } from './utils/decomposeRotation';
import { quatInvertCompat } from './utils/quatInvertCompat';
import { quatInvertCompat } from '@pixiv/three-vrm-utils';
import { VRMNodeConstraint } from './VRMNodeConstraint';

const _v3A = new THREE.Vector3();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as THREE from 'three';
import type { VRMNodeConstraint } from './VRMNodeConstraint';
import { traverseAncestorsFromRoot } from './utils/traverseAncestorsFromRoot';
import { traverseAncestorsFromRoot } from '@pixiv/three-vrm-utils';

export class VRMNodeConstraintManager {
private _constraints = new Set<VRMNodeConstraint>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as THREE from 'three';
import { quatInvertCompat } from './utils/quatInvertCompat';
import { quatInvertCompat } from '@pixiv/three-vrm-utils';
import { VRMNodeConstraint } from './VRMNodeConstraint';

const _v3A = new THREE.Vector3();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as THREE from 'three';
import { quatInvertCompat } from './utils/quatInvertCompat';
import { quatInvertCompat } from '@pixiv/three-vrm-utils';
import { VRMNodeConstraint } from './VRMNodeConstraint';

const _quatA = new THREE.Quaternion();
Expand Down

This file was deleted.

17 changes: 0 additions & 17 deletions packages/three-vrm-node-constraint/src/utils/quatInvertCompat.ts

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions packages/three-vrm-springbone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
]
},
"dependencies": {
"@pixiv/three-vrm-utils": "1.0.6",
"@pixiv/types-vrm-0.0": "1.0.0",
"@pixiv/types-vrmc-springbone-1.0": "1.0.0"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/three-vrm-springbone/src/VRMSpringBoneJoint.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as THREE from 'three';
import { mat4InvertCompat } from './utils/mat4InvertCompat';
import { Matrix4InverseCache } from './utils/Matrix4InverseCache';
import { mat4InvertCompat, Matrix4InverseCache } from '@pixiv/three-vrm-utils';
import type { VRMSpringBoneColliderGroup } from './VRMSpringBoneColliderGroup';
import type { VRMSpringBoneJointSettings } from './VRMSpringBoneJointSettings';

Expand Down
2 changes: 1 addition & 1 deletion packages/three-vrm-springbone/src/VRMSpringBoneManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type * as THREE from 'three';
import type { VRMSpringBoneJoint } from './VRMSpringBoneJoint';
import { traverseAncestorsFromRoot } from './utils/traverseAncestorsFromRoot';
import { traverseAncestorsFromRoot } from '@pixiv/three-vrm-utils';
import type { VRMSpringBoneCollider } from './VRMSpringBoneCollider';
import type { VRMSpringBoneColliderGroup } from './VRMSpringBoneColliderGroup';
import { traverseChildrenUntilConditionMet } from './utils/traverseChildrenUntilConditionMet';
Expand Down
60 changes: 0 additions & 60 deletions packages/three-vrm-springbone/src/utils/Matrix4InverseCache.ts

This file was deleted.

15 changes: 0 additions & 15 deletions packages/three-vrm-springbone/src/utils/getWorldQuaternionLite.ts

This file was deleted.

19 changes: 0 additions & 19 deletions packages/three-vrm-springbone/src/utils/mat4InvertCompat.ts

This file was deleted.

9 changes: 9 additions & 0 deletions packages/three-vrm-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @pixiv/three-vrm-utils

Utility module for @pixiv/three-vrm. Primarily intended for internal use

[GitHub Repository](https://github.com/pixiv/three-vrm/tree/dev/packages/three-vrm-utils)

[Examples](https://pixiv.github.io/three-vrm/packages/three-vrm-utils/examples)

[Documentation](https://pixiv.github.io/three-vrm/packages/three-vrm-utils/docs)
19 changes: 19 additions & 0 deletions packages/three-vrm-utils/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module.exports = {
"roots": [
"<rootDir>/src"
],
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "[^.]*.test.ts$",
"moduleFileExtensions": [
"ts",
"js",
"json",
"node"
],
"collectCoverageFrom": [
"**/*.ts",
"!**/tests/**"
]
}
52 changes: 52 additions & 0 deletions packages/three-vrm-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "@pixiv/three-vrm-utils",
"version": "1.0.6",
"description": "Utility module for @pixiv/three-vrm. Primarily intended for internal use",
"license": "MIT",
"author": "pixiv",
"files": [
"/lib/",
"/ts*/",
"/types/",
"LICENSE"
],
"main": "lib/three-vrm-utils.js",
"module": "lib/three-vrm-utils.module.js",
"types": "types/index.d.ts",
"typesVersions": {
"<3.9": {
"*": [
"ts3.4/*"
]
}
},
"scripts": {
"version": "yarn all",
"all": "yarn lint && yarn clean && yarn build && yarn docs",
"dev": "cross-env NODE_ENV=development rollup -w -c",
"clean": "rimraf docs/ lib/ ts*/ types/",
"build": "yarn build-dev && yarn build-prod && yarn build-types",
"build-dev": "cross-env NODE_ENV=development rollup -c",
"build-prod": "cross-env NODE_ENV=production rollup -c",
"build-types": "tsc --declaration --declarationDir ./types --emitDeclarationOnly && downlevel-dts types ts3.4/types",
"docs": "typedoc --entryPoints ./src/index.ts --out docs",
"test": "jest",
"lint": "eslint \"src/**/*.{ts,tsx}\" && prettier \"src/**/*.{ts,tsx}\" --check",
"lint-fix": "eslint \"src/**/*.{ts,tsx}\" --fix && prettier \"src/**/*.{ts,tsx}\" --write"
},
"lint-staged": {
"./src/**/*.{ts,tsx}": [
"eslint --fix",
"prettier --write"
]
},
"devDependencies": {
"@types/three": "^0.146.0",
"lint-staged": "13.0.3",
"three": "^0.146.0"
},
"peerDependencies": {
"@types/three": "^0.146.0",
"three": "^0.146.0"
}
}
Loading

0 comments on commit 304b70d

Please sign in to comment.