Skip to content

Commit 32167b5

Browse files
committed
feat: init
1 parent 2b44b7a commit 32167b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+13425
-0
lines changed

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
max_line_length = 120

.eslintrc.js

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
module.exports = {
2+
root: true,
3+
parser: "@typescript-eslint/parser",
4+
parserOptions: {
5+
tsconfigRootDir: __dirname,
6+
project: ["./tsconfig.json"],
7+
},
8+
env: {
9+
browser: true,
10+
node: true,
11+
mocha: true,
12+
},
13+
globals: { 'chai': true },
14+
ignorePatterns: [
15+
'**/{node_modules,libs}',
16+
'*.js',
17+
'*.d.ts',
18+
],
19+
extends: [
20+
"eslint:recommended",
21+
"plugin:@typescript-eslint/recommended",
22+
"plugin:promise/recommended",
23+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
24+
],
25+
plugins: [
26+
"@typescript-eslint",
27+
],
28+
rules: {
29+
"arrow-parens": ["error", "as-needed"],
30+
"array-bracket-spacing": ["error", "never"],
31+
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
32+
"comma-dangle": ["error", "always-multiline"],
33+
"curly": "error",
34+
"generator-star-spacing": ["error", {
35+
"before": false,
36+
"after": true,
37+
"anonymous": "neither",
38+
"method": "neither"
39+
}],
40+
"new-parens": "error",
41+
"no-multi-spaces": [
42+
"error",
43+
{
44+
"ignoreEOLComments": true
45+
}
46+
],
47+
"no-console": ["error", { "allow": ["info", "warn", "error", "debug", "trace"] }],
48+
"no-inner-declarations": "error",
49+
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
50+
"no-trailing-spaces": "error",
51+
"no-void": ["error", { "allowAsStatement": true }],
52+
"padding-line-between-statements": [
53+
"error",
54+
{ "blankLine": "always", "prev": "*", "next": ["return", "break"] },
55+
{ "blankLine": "never", "prev": "*", "next": ["case", "default"] },
56+
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
57+
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] }
58+
],
59+
"promise/always-return": "off",
60+
// TODO:: will be opened
61+
"promise/catch-or-return": "off",
62+
"prefer-rest-params": "off",
63+
"semi": ["error", "always"],
64+
"space-in-parens": ["error", "never"],
65+
"@typescript-eslint/comma-spacing": "error",
66+
"@typescript-eslint/no-namespace": "off",
67+
// TODO:: will be ["error", "never"]
68+
"import/prefer-default-export": "off",
69+
"@typescript-eslint/explicit-module-boundary-types": "off",
70+
"@typescript-eslint/no-unused-vars": "off",
71+
"@typescript-eslint/ban-ts-comment": "off",
72+
// TODO:: will be opened
73+
"@typescript-eslint/ban-types": "off",
74+
"@typescript-eslint/indent": ["error", 2],
75+
"@typescript-eslint/keyword-spacing": "error",
76+
// TODO:: will be opened
77+
"@typescript-eslint/no-var-requires": "off",
78+
// TODO:: will be opened
79+
"@typescript-eslint/no-non-null-assertion": "off",
80+
// TODO:: will be opened
81+
"@typescript-eslint/no-explicit-any": "off",
82+
"@typescript-eslint/no-empty-interface": "off",
83+
"@typescript-eslint/no-empty-function": "off",
84+
"@typescript-eslint/no-unnecessary-type-arguments": "error",
85+
"@typescript-eslint/no-unnecessary-type-assertion": "error",
86+
"@typescript-eslint/no-unnecessary-type-constraint": "error",
87+
// TODO:: will be opened
88+
"@typescript-eslint/no-unsafe-return": "off",
89+
// TODO:: will be opened
90+
"@typescript-eslint/no-unsafe-member-access": "off",
91+
"@typescript-eslint/no-unsafe-call": "off",
92+
"@typescript-eslint/object-curly-spacing": ["error", "always"],
93+
"@typescript-eslint/prefer-includes": "error",
94+
"@typescript-eslint/prefer-reduce-type-parameter": "error",
95+
"@typescript-eslint/prefer-ts-expect-error": "error",
96+
"@typescript-eslint/return-await": "error",
97+
// TODO:: will be opened
98+
"@typescript-eslint/restrict-plus-operands": "off",
99+
// TODO:: will be opened
100+
"@typescript-eslint/restrict-template-expressions": "off",
101+
"@typescript-eslint/space-infix-ops": ["error", { "int32Hint": false }],
102+
// TODO:: will be "error"
103+
"@typescript-eslint/strict-boolean-expressions": "off",
104+
"@typescript-eslint/no-floating-promises": ["error", { "ignoreVoid": true, "ignoreIIFE": true }],
105+
"@typescript-eslint/quotes": ["error", "single"],
106+
// TODO:: will be opened
107+
"@typescript-eslint/require-await": "off",
108+
"@typescript-eslint/space-before-blocks": "error",
109+
"@typescript-eslint/space-before-function-paren": ["error", "always"],
110+
"@typescript-eslint/type-annotation-spacing": "error",
111+
"@typescript-eslint/unbound-method": "off",
112+
// TODO:: will be opened
113+
"@typescript-eslint/no-misused-promises": "off",
114+
"@typescript-eslint/prefer-regexp-exec": "off",
115+
"@typescript-eslint/semi": "error",
116+
// TODO:: will be opened
117+
"@typescript-eslint/member-delimiter-style": ["error", {
118+
"multiline": {
119+
"delimiter": "comma",
120+
"requireLast": true
121+
},
122+
"singleline": {
123+
"delimiter": "comma",
124+
"requireLast": false
125+
}
126+
}],
127+
"@typescript-eslint/no-unsafe-assignment": "off",
128+
// TODO:: will be opened
129+
"@typescript-eslint/no-unsafe-argument": "off",
130+
"@typescript-eslint/consistent-type-imports": [
131+
"error",
132+
{
133+
"prefer": "type-imports",
134+
"disallowTypeAnnotations": false,
135+
},
136+
],
137+
},
138+
};

.gitignore

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### macOS template
3+
# General
4+
.DS_Store
5+
.AppleDouble
6+
.LSOverride
7+
8+
# Icon must end with two \r
9+
Icon
10+
11+
# Thumbnails
12+
._*
13+
14+
# Files that might appear in the root of a volume
15+
.DocumentRevisions-V100
16+
.fseventsd
17+
.Spotlight-V100
18+
.TemporaryItems
19+
.Trashes
20+
.VolumeIcon.icns
21+
.com.apple.timemachine.donotpresent
22+
23+
# Directories potentially created on remote AFP share
24+
.AppleDB
25+
.AppleDesktop
26+
Network Trash Folder
27+
Temporary Items
28+
.apdisk
29+
### Node template
30+
# Logs
31+
logs
32+
*.log
33+
npm-debug.log*
34+
yarn-debug.log*
35+
yarn-error.log*
36+
37+
# Runtime data
38+
pids
39+
*.pid
40+
*.seed
41+
*.pid.lock
42+
43+
# Directory for instrumented libs generated by jscoverage/JSCover
44+
lib-cov
45+
46+
# Coverage directory used by tools like istanbul
47+
coverage
48+
49+
# nyc test coverage
50+
.nyc_output
51+
52+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
53+
.grunt
54+
55+
# Bower dependency directory (https://bower.io/)
56+
bower_components
57+
58+
# node-waf configuration
59+
.lock-wscript
60+
61+
# Compiled binary addons (https://nodejs.org/api/addons.html)
62+
build/Release
63+
64+
# Dependency directories
65+
node_modules/
66+
jspm_packages/
67+
68+
# TypeScript v1 declaration files
69+
typings/
70+
71+
# Optional npm cache directory
72+
.npm
73+
74+
# Optional eslint cache
75+
.eslintcache
76+
77+
# Optional REPL history
78+
.node_repl_history
79+
80+
# Output of 'npm pack'
81+
*.tgz
82+
83+
# Yarn Integrity file
84+
.yarn-integrity
85+
86+
# dotenv environment variables file
87+
.env
88+
89+
# next.js build output
90+
.next
91+
92+
.idea
93+
.history
94+
dist
95+
dist-rollup
96+
test/dev/*
97+
node/index.js

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
PATH=$PATH:/usr/local/bin:/usr/local/sbin
4+
npx commitlint --edit "$1"

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
PATH=$PATH:/usr/local/bin:/usr/local/sbin
4+
npx lint-staged

.lintstagedrc.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"{src,fallback,test}/**/*.{ts,mjs}": [
3+
"eslint --cache --fix",
4+
"sh -c 'tsc -b tsconfig.check.json'"
5+
]
6+
}

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Galacean Effects JSON definition
2+
3+
## Environment Setup
4+
5+
- Node.js `>= 10.0.0`
6+
7+
## Development
8+
9+
``` bash
10+
# 1. Install dependencies (first time)
11+
npm install
12+
# 2. Build
13+
npm run build
14+
```
15+
16+
## Testing
17+
18+
``` bash
19+
npm run test
20+
```
21+
22+
> Open browser and open: http://localhost:9003/test/

commitlint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
};

fallback/camera.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import type { CameraContent, CameraPositionOverLifetime } from '../src/item/camera-item';
2+
import type { RotationOverLifetime } from '../src';
3+
import { deleteEmptyValue, ensureFixedNumber, ensureFixedVec3 } from './utils';
4+
5+
export function getStandardCameraContent (model: any): CameraContent {
6+
const opt = model.options;
7+
const ret: CameraContent = {
8+
options: {
9+
fov: opt.fov!,
10+
far: opt.far!,
11+
near: opt.near!,
12+
clipMode: opt.clipMode,
13+
},
14+
};
15+
16+
const velocityOverLifetime = model.velocityOverLifetime;
17+
18+
if (velocityOverLifetime || model.transform?.path) {
19+
const positionOverLifetime: CameraPositionOverLifetime = {
20+
path: ensureFixedVec3(model.transform?.path),
21+
linearX: ensureFixedNumber(velocityOverLifetime?.translateX),
22+
linearY: ensureFixedNumber(velocityOverLifetime?.translateY),
23+
linearZ: ensureFixedNumber(velocityOverLifetime?.translateZ),
24+
};
25+
26+
deleteEmptyValue(positionOverLifetime);
27+
ret.positionOverLifetime = positionOverLifetime;
28+
}
29+
30+
const rol = model.rotationOverLifetime;
31+
32+
if (rol) {
33+
const rotationOverLifetime: RotationOverLifetime = {
34+
separateAxes: rol.separateAxes,
35+
x: ensureFixedNumber(rol?.rotateX),
36+
y: ensureFixedNumber(rol?.rotateY),
37+
z: rol.separateAxes ? ensureFixedNumber(rol?.rotateZ) : ensureFixedNumber(rol.rotation),
38+
};
39+
40+
deleteEmptyValue(rotationOverLifetime);
41+
ret.rotationOverLifetime = rotationOverLifetime;
42+
}
43+
44+
return ret;
45+
}

0 commit comments

Comments
 (0)