create-definedmotion 0.1.1 → 0.1.3
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
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
|
-
}
|