create-definedmotion 0.1.0 → 0.1.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-definedmotion",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Create a new DefinedMotion animation project",
|
|
5
5
|
"author": "Hugo Olsson",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,4 +34,4 @@
|
|
|
34
34
|
"three.js",
|
|
35
35
|
"motion-graphics"
|
|
36
36
|
]
|
|
37
|
-
}
|
|
37
|
+
}
|
package/src/cli.js
CHANGED
|
@@ -3,7 +3,6 @@ import path from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import minimist from 'minimist';
|
|
6
|
-
import { execSync } from 'child_process';
|
|
7
6
|
|
|
8
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
8
|
const argv = minimist(process.argv.slice(2));
|
|
@@ -32,7 +31,7 @@ async function createProject() {
|
|
|
32
31
|
|
|
33
32
|
// Copy template
|
|
34
33
|
const templateDir = path.join(__dirname, '..', 'template');
|
|
35
|
-
|
|
34
|
+
|
|
36
35
|
console.log(chalk.gray('Creating project structure...'));
|
|
37
36
|
fs.copySync(templateDir, targetDir);
|
|
38
37
|
|
|
@@ -52,44 +51,19 @@ async function createProject() {
|
|
|
52
51
|
|
|
53
52
|
console.log(chalk.green('✓') + ' Project structure created');
|
|
54
53
|
|
|
55
|
-
//
|
|
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
|
|
54
|
+
// Always skip dependency installation; print next steps instead
|
|
74
55
|
console.log('\n' + chalk.bold.green('✨ Success!') + ' Created ' + chalk.cyan(projectName));
|
|
75
56
|
console.log('\n' + chalk.bold('Next steps:'));
|
|
76
57
|
console.log(chalk.gray('\n Navigate to your project:'));
|
|
77
58
|
console.log(' ' + chalk.cyan(`cd ${projectName}`));
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
console.log(chalk.gray('\n Install dependencies:'));
|
|
81
|
-
console.log(' ' + chalk.cyan('npm install'));
|
|
82
|
-
}
|
|
83
|
-
|
|
59
|
+
console.log(chalk.gray('\n Install dependencies:'));
|
|
60
|
+
console.log(' ' + chalk.cyan('npm install'));
|
|
84
61
|
console.log(chalk.gray('\n Start development:'));
|
|
85
62
|
console.log(' ' + chalk.cyan('npm run dev'));
|
|
86
|
-
|
|
87
63
|
console.log(chalk.gray('\n Create your animations in:'));
|
|
88
64
|
console.log(' ' + chalk.cyan('src/renderer/src/scenes/'));
|
|
89
|
-
|
|
90
65
|
console.log('\n' + chalk.gray('Need help? Check out the docs:'));
|
|
91
66
|
console.log(' ' + chalk.cyan('https://github.com/HugoOlsson/DefinedMotion'));
|
|
92
|
-
|
|
93
67
|
console.log('\n' + chalk.bold('Happy animating! 🚀\n'));
|
|
94
68
|
}
|
|
95
69
|
|
|
@@ -97,4 +71,4 @@ async function createProject() {
|
|
|
97
71
|
createProject().catch(error => {
|
|
98
72
|
console.error(chalk.red('Error:'), error.message);
|
|
99
73
|
process.exit(1);
|
|
100
|
-
});
|
|
74
|
+
});
|
package/template/src/entry.ts
CHANGED
|
@@ -10,11 +10,10 @@ import { tutorial_easy1 } from './example_scenes/tutorials/easy1'
|
|
|
10
10
|
import { tutorial_easy2 } from './example_scenes/tutorials/easy2'
|
|
11
11
|
import { tutorial_medium1 } from './example_scenes/tutorials/medium1'
|
|
12
12
|
import { tutorial_easy3 } from './example_scenes/tutorials/easy3'
|
|
13
|
-
import { fourierMachineScene } from './example_scenes/fourierMachineScene'
|
|
14
13
|
|
|
15
14
|
export const screenFps = 120 //Your screen fps
|
|
16
15
|
export const renderSkip = 2 //Will divide your screenFps with this for render output fps
|
|
17
16
|
export const animationFPSThrottle = 1 // Use to change preview fps, will divide your fps with this value
|
|
18
17
|
|
|
19
18
|
export const renderOutputFps = () => screenFps / renderSkip
|
|
20
|
-
export const entryScene: () => AnimatedScene = () =>
|
|
19
|
+
export const entryScene: () => AnimatedScene = () => tutorial_easy1()
|
|
File without changes
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { createBumpMap } from '$renderer/lib/rendering/bumpMaps/noise'
|
|
2
|
-
import { addHDRI, addSceneLighting, HDRIs, loadHDRIData } from '$renderer/lib/rendering/lighting3d'
|
|
3
|
-
import { createCircle } from '$renderer/lib/rendering/objects2d'
|
|
4
|
-
import { AnimatedScene, HotReloadSetting, SpaceSetting } from '$renderer/lib/scene/sceneClass'
|
|
5
|
-
|
|
6
|
-
import * as THREE from 'three'
|
|
7
|
-
|
|
8
|
-
interface Relation {
|
|
9
|
-
name: string
|
|
10
|
-
radius: (n: number) => number
|
|
11
|
-
k: (n: number) => number
|
|
12
|
-
phase: (n: number) => number
|
|
13
|
-
latexString: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const baseRadius = 5
|
|
17
|
-
|
|
18
|
-
const relation: Relation = {
|
|
19
|
-
name: 'Sawtooth Wave',
|
|
20
|
-
// all harmonics, amplitude ∝1/n with alternating sign
|
|
21
|
-
radius: (n) => ((2 * baseRadius) / (Math.PI * n)) * (-1) ** (n + 1),
|
|
22
|
-
k: (n) => n,
|
|
23
|
-
phase: () => 0,
|
|
24
|
-
latexString: String.raw`\sum_{n=1}^{N} \frac{2(-1)^{n+1}}{\pi n} \sin(nt)`
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const bumpMap = createBumpMap({
|
|
28
|
-
width: 512,
|
|
29
|
-
height: 512,
|
|
30
|
-
noiseAlgorithm: 'random',
|
|
31
|
-
intensity: 0.2
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
const material = new THREE.MeshStandardMaterial({
|
|
35
|
-
color: 0xffffff,
|
|
36
|
-
metalness: 1,
|
|
37
|
-
bumpMap: bumpMap,
|
|
38
|
-
roughness: 0.3,
|
|
39
|
-
side: THREE.DoubleSide
|
|
40
|
-
}) as any
|
|
41
|
-
|
|
42
|
-
function createRingGeometry(
|
|
43
|
-
innerRadius: number,
|
|
44
|
-
outerRadius: number,
|
|
45
|
-
thickness: number
|
|
46
|
-
): THREE.BufferGeometry {
|
|
47
|
-
// Create a rectangular cross-section that will be rotated around the Y axis
|
|
48
|
-
const points = [
|
|
49
|
-
new THREE.Vector2(innerRadius, -thickness / 2),
|
|
50
|
-
new THREE.Vector2(outerRadius, -thickness / 2),
|
|
51
|
-
new THREE.Vector2(outerRadius, thickness / 2),
|
|
52
|
-
new THREE.Vector2(innerRadius, thickness / 2),
|
|
53
|
-
new THREE.Vector2(innerRadius, -thickness / 2) // Close the shape
|
|
54
|
-
]
|
|
55
|
-
|
|
56
|
-
// Create geometry by rotating the shape around the Y axis
|
|
57
|
-
const geometry = new THREE.LatheGeometry(points, 100) // 100 segments for smoothness
|
|
58
|
-
|
|
59
|
-
return geometry
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function createFourierCircle(radius: number): THREE.Group {
|
|
63
|
-
const group = new THREE.Group()
|
|
64
|
-
const circleThickness = 0.2
|
|
65
|
-
const nobRadius = 0.3
|
|
66
|
-
|
|
67
|
-
// Create ring with proper surfaces
|
|
68
|
-
const circleGeometry = createRingGeometry(nobRadius * 1.1, radius, circleThickness)
|
|
69
|
-
const circle = new THREE.Mesh(circleGeometry, material)
|
|
70
|
-
circle.rotation.x = Math.PI / 2
|
|
71
|
-
circle.castShadow = true
|
|
72
|
-
circle.receiveShadow = true
|
|
73
|
-
group.add(circle)
|
|
74
|
-
|
|
75
|
-
const nobHeight = 1
|
|
76
|
-
const nobGeometry = new THREE.CylinderGeometry(nobRadius, nobRadius, nobHeight, 32)
|
|
77
|
-
const nob = new THREE.Mesh(nobGeometry, material)
|
|
78
|
-
nob.rotation.x = Math.PI / 2
|
|
79
|
-
nob.position.x = radius - nobRadius * 2
|
|
80
|
-
nob.position.z = circleThickness / 2 + nobHeight / 2
|
|
81
|
-
nob.castShadow = true
|
|
82
|
-
nob.receiveShadow = true
|
|
83
|
-
group.add(nob)
|
|
84
|
-
|
|
85
|
-
return group
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const hdriData = await loadHDRIData(HDRIs.indoor1, 2, 1)
|
|
89
|
-
|
|
90
|
-
export function fourierMachineScene(): AnimatedScene {
|
|
91
|
-
return new AnimatedScene(
|
|
92
|
-
1080,
|
|
93
|
-
1920,
|
|
94
|
-
SpaceSetting.ThreeDim,
|
|
95
|
-
HotReloadSetting.TraceFromStart,
|
|
96
|
-
async (dmScene) => {
|
|
97
|
-
dmScene.renderer.shadowMap.enabled = true
|
|
98
|
-
dmScene.renderer.shadowMap.type = THREE.PCFSoftShadowMap
|
|
99
|
-
const circle = createFourierCircle(6)
|
|
100
|
-
await addHDRI(dmScene, hdriData, 0.3)
|
|
101
|
-
addSceneLighting(dmScene.scene)
|
|
102
|
-
dmScene.add(circle)
|
|
103
|
-
|
|
104
|
-
const axesHelper = new THREE.AxesHelper(15) // Size of 15 units
|
|
105
|
-
dmScene.add(axesHelper)
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
}
|