perpetual-motion.ts 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. import { PI } from "./_helpers";
  2. import type { Scene } from "./_helpers";
  3. export const perpetualMotion: Scene = {
  4. name: "Perpetual Motion Machine",
  5. description:
  6. "A gyroscope/gimbal with 3 nested spinning rings on different axes, with a perfectly still glass sphere floating at the center. Clean, minimal, mesmerizing.",
  7. spec: {
  8. root: "scene",
  9. elements: {
  10. scene: {
  11. type: "Group",
  12. props: { position: null, rotation: null, scale: null },
  13. children: [
  14. "env",
  15. "ambient",
  16. "key",
  17. "fill",
  18. "outer-spin",
  19. "sparkles",
  20. "floor",
  21. "shadows",
  22. "post",
  23. "controls",
  24. ],
  25. },
  26. env: {
  27. type: "Environment",
  28. props: {
  29. preset: "studio",
  30. background: false,
  31. blur: null,
  32. intensity: 1,
  33. },
  34. children: [],
  35. },
  36. ambient: {
  37. type: "AmbientLight",
  38. props: { color: "#ffffff", intensity: 0.3 },
  39. children: [],
  40. },
  41. key: {
  42. type: "DirectionalLight",
  43. props: {
  44. position: [5, 8, 5],
  45. rotation: null,
  46. scale: null,
  47. color: "#ffffff",
  48. intensity: 2,
  49. castShadow: true,
  50. },
  51. children: [],
  52. },
  53. fill: {
  54. type: "PointLight",
  55. props: {
  56. position: [-3, 4, -3],
  57. rotation: null,
  58. scale: null,
  59. color: "#aaccff",
  60. intensity: 10,
  61. distance: 15,
  62. decay: 2,
  63. castShadow: false,
  64. },
  65. children: [],
  66. },
  67. "outer-spin": {
  68. type: "Spin",
  69. props: {
  70. position: null,
  71. rotation: null,
  72. scale: null,
  73. speed: 0.4,
  74. axis: "y",
  75. },
  76. children: ["outer-ring", "mid-spin"],
  77. },
  78. "outer-ring": {
  79. type: "Torus",
  80. props: {
  81. position: null,
  82. rotation: [PI / 2, 0, 0],
  83. scale: null,
  84. castShadow: false,
  85. receiveShadow: false,
  86. material: {
  87. color: "#cccccc",
  88. metalness: 1,
  89. roughness: 0.05,
  90. emissive: "#ffffff",
  91. emissiveIntensity: 0.05,
  92. opacity: null,
  93. transparent: null,
  94. wireframe: null,
  95. },
  96. radius: 4,
  97. tube: 0.06,
  98. radialSegments: null,
  99. tubularSegments: 128,
  100. },
  101. children: [],
  102. },
  103. "mid-spin": {
  104. type: "Spin",
  105. props: {
  106. position: null,
  107. rotation: null,
  108. scale: null,
  109. speed: -0.8,
  110. axis: "x",
  111. },
  112. children: ["mid-ring", "inner-spin"],
  113. },
  114. "mid-ring": {
  115. type: "Torus",
  116. props: {
  117. position: null,
  118. rotation: [PI / 2, 0, 0],
  119. scale: null,
  120. castShadow: false,
  121. receiveShadow: false,
  122. material: {
  123. color: "#ffcc44",
  124. metalness: 0.95,
  125. roughness: 0.08,
  126. emissive: "#cc9900",
  127. emissiveIntensity: 0.1,
  128. opacity: null,
  129. transparent: null,
  130. wireframe: null,
  131. },
  132. radius: 3,
  133. tube: 0.05,
  134. radialSegments: null,
  135. tubularSegments: 128,
  136. },
  137. children: [],
  138. },
  139. "inner-spin": {
  140. type: "Spin",
  141. props: {
  142. position: null,
  143. rotation: null,
  144. scale: null,
  145. speed: 1.5,
  146. axis: "z",
  147. },
  148. children: ["inner-ring", "center-float"],
  149. },
  150. "inner-ring": {
  151. type: "Torus",
  152. props: {
  153. position: null,
  154. rotation: [PI / 2, 0, 0],
  155. scale: null,
  156. castShadow: false,
  157. receiveShadow: false,
  158. material: {
  159. color: "#cc8844",
  160. metalness: 0.9,
  161. roughness: 0.1,
  162. emissive: "#996633",
  163. emissiveIntensity: 0.1,
  164. opacity: null,
  165. transparent: null,
  166. wireframe: null,
  167. },
  168. radius: 2,
  169. tube: 0.04,
  170. radialSegments: null,
  171. tubularSegments: 128,
  172. },
  173. children: [],
  174. },
  175. "center-float": {
  176. type: "Float",
  177. props: {
  178. position: [0, 0, 0],
  179. rotation: null,
  180. scale: null,
  181. speed: 0.3,
  182. rotationIntensity: 0,
  183. floatIntensity: 0.1,
  184. enabled: true,
  185. },
  186. children: ["center-orb"],
  187. },
  188. "center-orb": {
  189. type: "GlassSphere",
  190. props: {
  191. position: null,
  192. rotation: null,
  193. scale: null,
  194. castShadow: true,
  195. receiveShadow: false,
  196. radius: 0.8,
  197. widthSegments: 64,
  198. heightSegments: 32,
  199. color: "#ffffff",
  200. transmission: 1,
  201. thickness: 1,
  202. roughness: 0,
  203. chromaticAberration: 0.12,
  204. ior: 2,
  205. distortion: 0.1,
  206. distortionScale: 0.4,
  207. temporalDistortion: 0.4,
  208. samples: 10,
  209. resolution: 256,
  210. },
  211. children: [],
  212. },
  213. sparkles: {
  214. type: "Sparkles",
  215. props: {
  216. position: [0, 0, 0],
  217. rotation: null,
  218. scale: [10, 10, 10],
  219. count: 100,
  220. speed: 0.1,
  221. opacity: 0.2,
  222. color: "#ccddff",
  223. size: 0.8,
  224. noise: 2,
  225. },
  226. children: [],
  227. },
  228. floor: {
  229. type: "ReflectorPlane",
  230. props: {
  231. position: [0, -4.5, 0],
  232. rotation: [-PI / 2, 0, 0],
  233. scale: null,
  234. width: 25,
  235. height: 25,
  236. color: "#1a1a2a",
  237. resolution: 1024,
  238. blur: 400,
  239. mirror: 0.7,
  240. mixBlur: 10,
  241. mixStrength: 2,
  242. depthScale: 0.2,
  243. metalness: 0.5,
  244. roughness: 1,
  245. },
  246. children: [],
  247. },
  248. shadows: {
  249. type: "ContactShadows",
  250. props: {
  251. position: [0, -4.5, 0],
  252. rotation: null,
  253. scale: null,
  254. opacity: 0.3,
  255. width: 12,
  256. height: 12,
  257. blur: 2.5,
  258. near: null,
  259. far: 10,
  260. smooth: true,
  261. resolution: 512,
  262. frames: null,
  263. color: "#000000",
  264. },
  265. children: [],
  266. },
  267. post: {
  268. type: "EffectComposer",
  269. props: { enabled: true, multisampling: 8 },
  270. children: ["bloom", "vignette"],
  271. },
  272. bloom: {
  273. type: "Bloom",
  274. props: {
  275. intensity: 0.8,
  276. luminanceThreshold: 0.25,
  277. luminanceSmoothing: null,
  278. mipmapBlur: true,
  279. },
  280. children: [],
  281. },
  282. vignette: {
  283. type: "Vignette",
  284. props: { offset: 0.5, darkness: 0.4 },
  285. children: [],
  286. },
  287. controls: {
  288. type: "OrbitControls",
  289. props: {
  290. enableDamping: true,
  291. dampingFactor: null,
  292. enableZoom: true,
  293. enablePan: null,
  294. enableRotate: true,
  295. minDistance: 5,
  296. maxDistance: 16,
  297. minPolarAngle: 0.3,
  298. maxPolarAngle: 1.5,
  299. autoRotate: true,
  300. autoRotateSpeed: 0.3,
  301. },
  302. children: [],
  303. },
  304. },
  305. },
  306. };