create-definedmotion 0.1.0
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.
- package/bin/index.js +3 -0
- package/package.json +37 -0
- package/src/cli.js +100 -0
- package/template/.editorconfig +9 -0
- package/template/.prettierignore +6 -0
- package/template/.prettierrc.yaml +10 -0
- package/template/_gitignore +10 -0
- package/template/build/entitlements.mac.plist +12 -0
- package/template/build/icon.icns +0 -0
- package/template/build/icon.ico +0 -0
- package/template/build/icon.png +0 -0
- package/template/electron-builder.yml +43 -0
- package/template/electron.vite.config.ts +50 -0
- package/template/eslint.config.mjs +24 -0
- package/template/package-lock.json +10299 -0
- package/template/package.json +64 -0
- package/template/resources/icon.png +0 -0
- package/template/src/assets/audio/fadeSound.mp3 +0 -0
- package/template/src/assets/audio/fadeSound2.mp3 +0 -0
- package/template/src/assets/audio/interstellar.mp3 +0 -0
- package/template/src/assets/audio/keyboard1.mp3 +0 -0
- package/template/src/assets/audio/keyboard2.mp3 +0 -0
- package/template/src/assets/audio/keyboard3.mp3 +0 -0
- package/template/src/assets/audio/tick_sound.mp3 +0 -0
- package/template/src/assets/base.css +67 -0
- package/template/src/assets/electron.svg +10 -0
- package/template/src/assets/fonts/Geo-Regular.woff +0 -0
- package/template/src/assets/fonts/Montserrat-Italic-VariableFont_wght.woff2 +0 -0
- package/template/src/assets/fonts/Montserrat-Medium.ttf +0 -0
- package/template/src/assets/fonts/Montserrat-Medium.woff +0 -0
- package/template/src/assets/fonts/Montserrat-VariableFont_wght.woff2 +0 -0
- package/template/src/assets/fonts/glitch.ttf +0 -0
- package/template/src/assets/hdri/indoor1.hdr +0 -0
- package/template/src/assets/hdri/metro1.hdr +0 -0
- package/template/src/assets/hdri/outdoor1.hdr +0 -0
- package/template/src/assets/hdri/photo-studio1.hdr +0 -0
- package/template/src/assets/hdri/photo-studio2.hdr +0 -0
- package/template/src/assets/hdri/photo-studio3.hdr +0 -0
- package/template/src/assets/objects/keyboardScene/ibm-keyboard.glb +0 -0
- package/template/src/assets/wavy-lines.svg +25 -0
- package/template/src/entry.ts +20 -0
- package/template/src/example_scenes/alternativesScene.ts +88 -0
- package/template/src/example_scenes/dependencyScene.ts +116 -0
- package/template/src/example_scenes/fourierMachineScene.ts +108 -0
- package/template/src/example_scenes/fourierSeriesScene.ts +678 -0
- package/template/src/example_scenes/keyboardScene.ts +447 -0
- package/template/src/example_scenes/surfaceScene.ts +88 -0
- package/template/src/example_scenes/tutorials/easy1.ts +59 -0
- package/template/src/example_scenes/tutorials/easy2.ts +141 -0
- package/template/src/example_scenes/tutorials/easy3.ts +133 -0
- package/template/src/example_scenes/tutorials/medium1.ts +154 -0
- package/template/src/example_scenes/vectorField.ts +209 -0
- package/template/src/example_scenes/visulizingFunctions.ts +246 -0
- package/template/src/main/index.ts +101 -0
- package/template/src/main/rendering.ts +219 -0
- package/template/src/main/storage.ts +35 -0
- package/template/src/preload/index.d.ts +8 -0
- package/template/src/preload/index.ts +36 -0
- package/template/src/renderer/index.html +17 -0
- package/template/src/renderer/src/App.svelte +130 -0
- package/template/src/renderer/src/app.css +24 -0
- package/template/src/renderer/src/env.d.ts +2 -0
- package/template/src/renderer/src/lib/animation/animations.ts +214 -0
- package/template/src/renderer/src/lib/animation/captureCanvas.ts +85 -0
- package/template/src/renderer/src/lib/animation/helpers.ts +7 -0
- package/template/src/renderer/src/lib/animation/interpolations.ts +155 -0
- package/template/src/renderer/src/lib/animation/protocols.ts +79 -0
- package/template/src/renderer/src/lib/audio/loader.ts +104 -0
- package/template/src/renderer/src/lib/fonts/Roboto_Regular.json +1 -0
- package/template/src/renderer/src/lib/fonts/montserrat-medium.json +1 -0
- package/template/src/renderer/src/lib/fonts/montserrat.json +1 -0
- package/template/src/renderer/src/lib/general/helpers.ts +77 -0
- package/template/src/renderer/src/lib/general/onDestory.ts +10 -0
- package/template/src/renderer/src/lib/mathHelpers/vectors.ts +18 -0
- package/template/src/renderer/src/lib/rendering/bumpMaps/noise.ts +84 -0
- package/template/src/renderer/src/lib/rendering/helpers.ts +35 -0
- package/template/src/renderer/src/lib/rendering/lighting3d.ts +387 -0
- package/template/src/renderer/src/lib/rendering/materials.ts +6 -0
- package/template/src/renderer/src/lib/rendering/objects/import.ts +148 -0
- package/template/src/renderer/src/lib/rendering/objects2d.ts +489 -0
- package/template/src/renderer/src/lib/rendering/objects3d.ts +89 -0
- package/template/src/renderer/src/lib/rendering/protocols.ts +21 -0
- package/template/src/renderer/src/lib/rendering/setup.ts +71 -0
- package/template/src/renderer/src/lib/rendering/svg/drawing.ts +213 -0
- package/template/src/renderer/src/lib/rendering/svg/parsing.ts +717 -0
- package/template/src/renderer/src/lib/rendering/svg/rastered.ts +42 -0
- package/template/src/renderer/src/lib/rendering/svgObjects.ts +1137 -0
- package/template/src/renderer/src/lib/scene/helpers.ts +89 -0
- package/template/src/renderer/src/lib/scene/sceneClass.ts +648 -0
- package/template/src/renderer/src/lib/shaders/background_gradient/frag.glsl +12 -0
- package/template/src/renderer/src/lib/shaders/background_gradient/vert.glsl +6 -0
- package/template/src/renderer/src/lib/shaders/hdri_blur/frag.glsl +45 -0
- package/template/src/renderer/src/lib/shaders/hdri_blur/vert.glsl +5 -0
- package/template/src/renderer/src/main.ts +9 -0
- package/template/svelte.config.mjs +7 -0
- package/template/tsconfig.json +4 -0
- package/template/tsconfig.node.json +10 -0
- package/template/tsconfig.web.json +32 -0
package/bin/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-definedmotion",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Create a new DefinedMotion animation project",
|
|
5
|
+
"author": "Hugo Olsson",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/HugoOlsson/DefinedMotion"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"bin": {
|
|
13
|
+
"create-definedmotion": "./bin/index.js"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"bin",
|
|
17
|
+
"src",
|
|
18
|
+
"template"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"test": "node bin/index.js test-project --skip-install"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"chalk": "^5.3.0",
|
|
28
|
+
"fs-extra": "^11.2.0",
|
|
29
|
+
"minimist": "^1.2.8"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"definedmotion",
|
|
33
|
+
"animation",
|
|
34
|
+
"three.js",
|
|
35
|
+
"motion-graphics"
|
|
36
|
+
]
|
|
37
|
+
}
|
package/src/cli.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import minimist from 'minimist';
|
|
6
|
+
import { execSync } from 'child_process';
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const argv = minimist(process.argv.slice(2));
|
|
10
|
+
|
|
11
|
+
async function createProject() {
|
|
12
|
+
const projectName = argv._[0];
|
|
13
|
+
|
|
14
|
+
if (!projectName) {
|
|
15
|
+
console.error(chalk.red('Error: Please provide a project name'));
|
|
16
|
+
console.log('\nUsage:');
|
|
17
|
+
console.log(' ' + chalk.cyan('create-definedmotion <project-name>'));
|
|
18
|
+
console.log('\nExample:');
|
|
19
|
+
console.log(' ' + chalk.cyan('create-definedmotion my-animation'));
|
|
20
|
+
process.exit(1);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
24
|
+
|
|
25
|
+
// Check if directory exists
|
|
26
|
+
if (fs.existsSync(targetDir)) {
|
|
27
|
+
console.error(chalk.red(`Error: Directory ${projectName} already exists`));
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log(chalk.blue('\n🎬 Creating DefinedMotion project...\n'));
|
|
32
|
+
|
|
33
|
+
// Copy template
|
|
34
|
+
const templateDir = path.join(__dirname, '..', 'template');
|
|
35
|
+
|
|
36
|
+
console.log(chalk.gray('Creating project structure...'));
|
|
37
|
+
fs.copySync(templateDir, targetDir);
|
|
38
|
+
|
|
39
|
+
// Update package.json with project name
|
|
40
|
+
const pkgPath = path.join(targetDir, 'package.json');
|
|
41
|
+
if (fs.existsSync(pkgPath)) {
|
|
42
|
+
const pkg = fs.readJsonSync(pkgPath);
|
|
43
|
+
pkg.name = projectName;
|
|
44
|
+
fs.writeJsonSync(pkgPath, pkg, { spaces: 2 });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Rename _gitignore to .gitignore if it exists
|
|
48
|
+
const gitignorePath = path.join(targetDir, '_gitignore');
|
|
49
|
+
if (fs.existsSync(gitignorePath)) {
|
|
50
|
+
fs.renameSync(gitignorePath, path.join(targetDir, '.gitignore'));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log(chalk.green('✓') + ' Project structure created');
|
|
54
|
+
|
|
55
|
+
// Install dependencies (unless skipped)
|
|
56
|
+
if (!argv['skip-install']) {
|
|
57
|
+
console.log(chalk.gray('\nInstalling dependencies (this may take a minute)...\n'));
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
execSync('npm install', {
|
|
61
|
+
cwd: targetDir,
|
|
62
|
+
stdio: 'inherit'
|
|
63
|
+
});
|
|
64
|
+
console.log('\n' + chalk.green('✓') + ' Dependencies installed');
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.log('\n' + chalk.yellow('⚠') + ' Failed to install dependencies');
|
|
67
|
+
console.log(chalk.gray(' You can install them manually:'));
|
|
68
|
+
console.log(' ' + chalk.cyan(`cd ${projectName}`));
|
|
69
|
+
console.log(' ' + chalk.cyan('npm install'));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Success message
|
|
74
|
+
console.log('\n' + chalk.bold.green('✨ Success!') + ' Created ' + chalk.cyan(projectName));
|
|
75
|
+
console.log('\n' + chalk.bold('Next steps:'));
|
|
76
|
+
console.log(chalk.gray('\n Navigate to your project:'));
|
|
77
|
+
console.log(' ' + chalk.cyan(`cd ${projectName}`));
|
|
78
|
+
|
|
79
|
+
if (argv['skip-install']) {
|
|
80
|
+
console.log(chalk.gray('\n Install dependencies:'));
|
|
81
|
+
console.log(' ' + chalk.cyan('npm install'));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
console.log(chalk.gray('\n Start development:'));
|
|
85
|
+
console.log(' ' + chalk.cyan('npm run dev'));
|
|
86
|
+
|
|
87
|
+
console.log(chalk.gray('\n Create your animations in:'));
|
|
88
|
+
console.log(' ' + chalk.cyan('src/renderer/src/scenes/'));
|
|
89
|
+
|
|
90
|
+
console.log('\n' + chalk.gray('Need help? Check out the docs:'));
|
|
91
|
+
console.log(' ' + chalk.cyan('https://github.com/HugoOlsson/DefinedMotion'));
|
|
92
|
+
|
|
93
|
+
console.log('\n' + chalk.bold('Happy animating! 🚀\n'));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Run
|
|
97
|
+
createProject().catch(error => {
|
|
98
|
+
console.error(chalk.red('Error:'), error.message);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>com.apple.security.cs.allow-jit</key>
|
|
6
|
+
<true/>
|
|
7
|
+
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
|
8
|
+
<true/>
|
|
9
|
+
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
|
|
10
|
+
<true/>
|
|
11
|
+
</dict>
|
|
12
|
+
</plist>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
appId: com.electron.app
|
|
2
|
+
productName: DefinedMotion
|
|
3
|
+
directories:
|
|
4
|
+
buildResources: build
|
|
5
|
+
files:
|
|
6
|
+
- '!**/.vscode/*'
|
|
7
|
+
- '!src/*'
|
|
8
|
+
- '!electron.vite.config.{js,ts,mjs,cjs}'
|
|
9
|
+
- '!{.eslintignore,.eslintrc.cjs,.prettierignore,.prettierrc.yaml,dev-app-update.yml,CHANGELOG.md,README.md}'
|
|
10
|
+
- '!{.env,.env.*,.npmrc,pnpm-lock.yaml}'
|
|
11
|
+
- '!{tsconfig.json,tsconfig.node.json,tsconfig.web.json}'
|
|
12
|
+
asarUnpack:
|
|
13
|
+
- resources/**
|
|
14
|
+
win:
|
|
15
|
+
executableName: DefinedMotion
|
|
16
|
+
nsis:
|
|
17
|
+
artifactName: ${name}-${version}-setup.${ext}
|
|
18
|
+
shortcutName: ${productName}
|
|
19
|
+
uninstallDisplayName: ${productName}
|
|
20
|
+
createDesktopShortcut: always
|
|
21
|
+
mac:
|
|
22
|
+
entitlementsInherit: build/entitlements.mac.plist
|
|
23
|
+
extendInfo:
|
|
24
|
+
- NSCameraUsageDescription: Application requests access to the device's camera.
|
|
25
|
+
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
|
|
26
|
+
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
|
|
27
|
+
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
|
|
28
|
+
notarize: false
|
|
29
|
+
dmg:
|
|
30
|
+
artifactName: ${name}-${version}.${ext}
|
|
31
|
+
linux:
|
|
32
|
+
target:
|
|
33
|
+
- AppImage
|
|
34
|
+
- snap
|
|
35
|
+
- deb
|
|
36
|
+
maintainer: electronjs.org
|
|
37
|
+
category: Utility
|
|
38
|
+
appImage:
|
|
39
|
+
artifactName: ${name}-${version}.${ext}
|
|
40
|
+
npmRebuild: false
|
|
41
|
+
publish:
|
|
42
|
+
provider: generic
|
|
43
|
+
url: https://example.com/auto-updates
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
|
2
|
+
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
3
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
4
|
+
import glsl from 'vite-plugin-glsl'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
import { fileURLToPath } from 'node:url'
|
|
7
|
+
|
|
8
|
+
const r = (p: string) => path.resolve(fileURLToPath(new URL('.', import.meta.url)), p)
|
|
9
|
+
|
|
10
|
+
export default defineConfig({
|
|
11
|
+
main: {
|
|
12
|
+
plugins: [externalizeDepsPlugin()]
|
|
13
|
+
},
|
|
14
|
+
preload: {
|
|
15
|
+
plugins: [externalizeDepsPlugin()]
|
|
16
|
+
},
|
|
17
|
+
renderer: {
|
|
18
|
+
plugins: [svelte(), tailwindcss(), glsl()],
|
|
19
|
+
assetsInclude: ['**/*.hdr'],
|
|
20
|
+
// Add Node.js built-in modules to the renderer process
|
|
21
|
+
resolve: {
|
|
22
|
+
// Ensure these modules can be used in the renderer
|
|
23
|
+
alias: {
|
|
24
|
+
fs: 'node:fs',
|
|
25
|
+
path: 'node:path',
|
|
26
|
+
os: 'node:os',
|
|
27
|
+
crypto: 'node:crypto',
|
|
28
|
+
$assets: r('src/assets'),
|
|
29
|
+
$renderer: r('src/renderer/src')
|
|
30
|
+
// Add other Node.js modules you need
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
// Configure how Node.js modules are handled
|
|
34
|
+
build: {
|
|
35
|
+
rollupOptions: {
|
|
36
|
+
external: [] // Empty to prevent externalizing Node modules
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
// Make Node.js built-ins available
|
|
40
|
+
server: {
|
|
41
|
+
watch: {
|
|
42
|
+
ignored: []
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
// Let the renderer process access Node.js APIs
|
|
46
|
+
optimizeDeps: {
|
|
47
|
+
exclude: ['electron']
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
})
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import tseslint from '@electron-toolkit/eslint-config-ts'
|
|
2
|
+
import eslintConfigPrettier from '@electron-toolkit/eslint-config-prettier'
|
|
3
|
+
import eslintPluginSvelte from 'eslint-plugin-svelte'
|
|
4
|
+
|
|
5
|
+
export default tseslint.config(
|
|
6
|
+
{ ignores: ['**/node_modules', '**/dist', '**/out'] },
|
|
7
|
+
tseslint.configs.recommended,
|
|
8
|
+
eslintPluginSvelte.configs['flat/recommended'],
|
|
9
|
+
{
|
|
10
|
+
files: ['**/*.svelte'],
|
|
11
|
+
languageOptions: {
|
|
12
|
+
parserOptions: {
|
|
13
|
+
parser: tseslint.parser
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
files: ['**/*.{tsx,svelte}'],
|
|
19
|
+
rules: {
|
|
20
|
+
'svelte/no-unused-svelte-ignore': 'off'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
eslintConfigPrettier
|
|
24
|
+
)
|