Skip to content

Commit

Permalink
feat: init
Browse files Browse the repository at this point in the history
yiiqii committed Nov 20, 2023
1 parent 2b44b7a commit 32167b5
Showing 67 changed files with 13,425 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120
138 changes: 138 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./tsconfig.json"],
},
env: {
browser: true,
node: true,
mocha: true,
},
globals: { 'chai': true },
ignorePatterns: [
'**/{node_modules,libs}',
'*.js',
'*.d.ts',
],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:promise/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
plugins: [
"@typescript-eslint",
],
rules: {
"arrow-parens": ["error", "as-needed"],
"array-bracket-spacing": ["error", "never"],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"comma-dangle": ["error", "always-multiline"],
"curly": "error",
"generator-star-spacing": ["error", {
"before": false,
"after": true,
"anonymous": "neither",
"method": "neither"
}],
"new-parens": "error",
"no-multi-spaces": [
"error",
{
"ignoreEOLComments": true
}
],
"no-console": ["error", { "allow": ["info", "warn", "error", "debug", "trace"] }],
"no-inner-declarations": "error",
"no-multiple-empty-lines": ["error", { "max": 1, "maxEOF": 1 }],
"no-trailing-spaces": "error",
"no-void": ["error", { "allowAsStatement": true }],
"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": "*", "next": ["return", "break"] },
{ "blankLine": "never", "prev": "*", "next": ["case", "default"] },
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*" },
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"] }
],
"promise/always-return": "off",
// TODO:: will be opened
"promise/catch-or-return": "off",
"prefer-rest-params": "off",
"semi": ["error", "always"],
"space-in-parens": ["error", "never"],
"@typescript-eslint/comma-spacing": "error",
"@typescript-eslint/no-namespace": "off",
// TODO:: will be ["error", "never"]
"import/prefer-default-export": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/ban-ts-comment": "off",
// TODO:: will be opened
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/indent": ["error", 2],
"@typescript-eslint/keyword-spacing": "error",
// TODO:: will be opened
"@typescript-eslint/no-var-requires": "off",
// TODO:: will be opened
"@typescript-eslint/no-non-null-assertion": "off",
// TODO:: will be opened
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-unnecessary-type-arguments": "error",
"@typescript-eslint/no-unnecessary-type-assertion": "error",
"@typescript-eslint/no-unnecessary-type-constraint": "error",
// TODO:: will be opened
"@typescript-eslint/no-unsafe-return": "off",
// TODO:: will be opened
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/object-curly-spacing": ["error", "always"],
"@typescript-eslint/prefer-includes": "error",
"@typescript-eslint/prefer-reduce-type-parameter": "error",
"@typescript-eslint/prefer-ts-expect-error": "error",
"@typescript-eslint/return-await": "error",
// TODO:: will be opened
"@typescript-eslint/restrict-plus-operands": "off",
// TODO:: will be opened
"@typescript-eslint/restrict-template-expressions": "off",
"@typescript-eslint/space-infix-ops": ["error", { "int32Hint": false }],
// TODO:: will be "error"
"@typescript-eslint/strict-boolean-expressions": "off",
"@typescript-eslint/no-floating-promises": ["error", { "ignoreVoid": true, "ignoreIIFE": true }],
"@typescript-eslint/quotes": ["error", "single"],
// TODO:: will be opened
"@typescript-eslint/require-await": "off",
"@typescript-eslint/space-before-blocks": "error",
"@typescript-eslint/space-before-function-paren": ["error", "always"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "off",
// TODO:: will be opened
"@typescript-eslint/no-misused-promises": "off",
"@typescript-eslint/prefer-regexp-exec": "off",
"@typescript-eslint/semi": "error",
// TODO:: will be opened
"@typescript-eslint/member-delimiter-style": ["error", {
"multiline": {
"delimiter": "comma",
"requireLast": true
},
"singleline": {
"delimiter": "comma",
"requireLast": false
}
}],
"@typescript-eslint/no-unsafe-assignment": "off",
// TODO:: will be opened
"@typescript-eslint/no-unsafe-argument": "off",
"@typescript-eslint/consistent-type-imports": [
"error",
{
"prefer": "type-imports",
"disallowTypeAnnotations": false,
},
],
},
};
97 changes: 97 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Created by .ignore support plugin (hsz.mobi)
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Node template
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next

.idea
.history
dist
dist-rollup
test/dev/*
node/index.js
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
PATH=$PATH:/usr/local/bin:/usr/local/sbin
npx commitlint --edit "$1"
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
PATH=$PATH:/usr/local/bin:/usr/local/sbin
npx lint-staged
6 changes: 6 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"{src,fallback,test}/**/*.{ts,mjs}": [
"eslint --cache --fix",
"sh -c 'tsc -b tsconfig.check.json'"
]
}
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Galacean Effects JSON definition

## Environment Setup

- Node.js `>= 10.0.0`

## Development

``` bash
# 1. Install dependencies (first time)
npm install
# 2. Build
npm run build
```

## Testing

``` bash
npm run test
```

> Open browser and open: http://localhost:9003/test/
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
45 changes: 45 additions & 0 deletions fallback/camera.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { CameraContent, CameraPositionOverLifetime } from '../src/item/camera-item';
import type { RotationOverLifetime } from '../src';
import { deleteEmptyValue, ensureFixedNumber, ensureFixedVec3 } from './utils';

export function getStandardCameraContent (model: any): CameraContent {
const opt = model.options;
const ret: CameraContent = {
options: {
fov: opt.fov!,
far: opt.far!,
near: opt.near!,
clipMode: opt.clipMode,
},
};

const velocityOverLifetime = model.velocityOverLifetime;

if (velocityOverLifetime || model.transform?.path) {
const positionOverLifetime: CameraPositionOverLifetime = {
path: ensureFixedVec3(model.transform?.path),
linearX: ensureFixedNumber(velocityOverLifetime?.translateX),
linearY: ensureFixedNumber(velocityOverLifetime?.translateY),
linearZ: ensureFixedNumber(velocityOverLifetime?.translateZ),
};

deleteEmptyValue(positionOverLifetime);
ret.positionOverLifetime = positionOverLifetime;
}

const rol = model.rotationOverLifetime;

if (rol) {
const rotationOverLifetime: RotationOverLifetime = {
separateAxes: rol.separateAxes,
x: ensureFixedNumber(rol?.rotateX),
y: ensureFixedNumber(rol?.rotateY),
z: rol.separateAxes ? ensureFixedNumber(rol?.rotateZ) : ensureFixedNumber(rol.rotation),
};

deleteEmptyValue(rotationOverLifetime);
ret.rotationOverLifetime = rotationOverLifetime;
}

return ret;
}
33 changes: 33 additions & 0 deletions fallback/filter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ensureFixedNumber, ensureFixedVec3, forEach } from './utils';
import type { FilterParams } from '../src/item/filter-item';

const convertParams = [
'strength',
'bloomAddon',
'colorAddon',
'period',
'waveMovement',
'colorThreshold',
'xOpacity',
'yOpacity',
'feather',
];
const pathParams = [
'path', 'position',
];

export function getStandardFilterContent (filter: any): FilterParams {
const ret: Record<string, any> = {};

forEach(filter, function (val, key) {
if (convertParams.includes(key)) {
ret[key] = ensureFixedNumber(val);
} else if (pathParams.includes(key)) {
ret[key] = ensureFixedVec3(val);
} else {
ret[key] = val;
}
});

return ret as FilterParams;
}
Loading

0 comments on commit 32167b5

Please sign in to comment.