@tarsis/toolkit 0.4.8 → 0.5.1

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.
Files changed (97) hide show
  1. package/dist/fonts/GT-Flexa-VF-Trial.woff2 +0 -0
  2. package/dist/fonts/GT-Maru-Light-Oblique-Trial.woff2 +0 -0
  3. package/dist/fonts/GT-Maru-Light-Trial.woff2 +0 -0
  4. package/dist/fonts/GT-Maru-Medium-Oblique-Trial.woff2 +0 -0
  5. package/dist/fonts/GT-Maru-Medium-Trial.woff2 +0 -0
  6. package/dist/fonts/GT-Maru-Mono-Black-Oblique-Trial.woff2 +0 -0
  7. package/dist/fonts/GT-Maru-Mono-Black-Trial.woff2 +0 -0
  8. package/dist/fonts/GT-Maru-Mono-Bold-Oblique-Trial.woff2 +0 -0
  9. package/dist/fonts/GT-Maru-Mono-Bold-Trial.woff2 +0 -0
  10. package/dist/fonts/GT-Maru-Mono-Light-Oblique-Trial.woff2 +0 -0
  11. package/dist/fonts/GT-Maru-Mono-Light-Trial.woff2 +0 -0
  12. package/dist/fonts/GT-Maru-Mono-Medium-Oblique-Trial.woff2 +0 -0
  13. package/dist/fonts/GT-Maru-Mono-Medium-Trial.woff2 +0 -0
  14. package/dist/fonts/gt/maru/GT-Maru-Light-Oblique-Trial.woff2 +0 -0
  15. package/dist/fonts/gt/maru/GT-Maru-Light-Trial.woff2 +0 -0
  16. package/dist/fonts/gt/maru/GT-Maru-Medium-Oblique-Trial.woff2 +0 -0
  17. package/dist/fonts/gt/maru/GT-Maru-Medium-Trial.woff2 +0 -0
  18. package/dist/fonts/gt/maru/GT-Maru-Mono-Black-Oblique-Trial.woff2 +0 -0
  19. package/dist/fonts/gt/maru/GT-Maru-Mono-Black-Trial.woff2 +0 -0
  20. package/dist/fonts/gt/maru/GT-Maru-Mono-Bold-Oblique-Trial.woff2 +0 -0
  21. package/dist/fonts/gt/maru/GT-Maru-Mono-Bold-Trial.woff2 +0 -0
  22. package/dist/fonts/gt/maru/GT-Maru-Mono-Light-Oblique-Trial.woff2 +0 -0
  23. package/dist/fonts/gt/maru/GT-Maru-Mono-Light-Trial.woff2 +0 -0
  24. package/dist/fonts/gt/maru/GT-Maru-Mono-Medium-Oblique-Trial.woff2 +0 -0
  25. package/dist/fonts/gt/maru/GT-Maru-Mono-Medium-Trial.woff2 +0 -0
  26. package/dist/fonts/gt/maru/gt-maru-black-oblique.woff2 +0 -0
  27. package/dist/fonts/gt/maru/gt-maru-black.woff2 +0 -0
  28. package/dist/fonts/gt/maru/gt-maru-bold-oblique.woff2 +0 -0
  29. package/dist/fonts/gt/maru/gt-maru-bold.woff2 +0 -0
  30. package/dist/fonts/gt/maru/gt-maru-mega-l.woff2 +0 -0
  31. package/dist/fonts/gt/maru/gt-maru-mega-m.woff2 +0 -0
  32. package/dist/fonts/gt/maru/gt-maru-mega-s.woff2 +0 -0
  33. package/dist/fonts/gt/maru/gt-maru-mono-regular-oblique.woff2 +0 -0
  34. package/dist/fonts/gt/maru/gt-maru-mono-regular.woff2 +0 -0
  35. package/dist/fonts/gt/maru/gt-maru-regular-oblique.woff2 +0 -0
  36. package/dist/fonts/gt/maru/gt-maru-regular.woff2 +0 -0
  37. package/dist/fonts/gt-flexa/GT-Flexa-VF-Trial.woff2 +0 -0
  38. package/dist/fonts/gt-maru-black-oblique.woff2 +0 -0
  39. package/dist/fonts/gt-maru-black.woff2 +0 -0
  40. package/dist/fonts/gt-maru-bold-oblique.woff2 +0 -0
  41. package/dist/fonts/gt-maru-bold.woff2 +0 -0
  42. package/dist/fonts/gt-maru-mega-l.woff2 +0 -0
  43. package/dist/fonts/gt-maru-mega-m.woff2 +0 -0
  44. package/dist/fonts/gt-maru-mega-s.woff2 +0 -0
  45. package/dist/fonts/gt-maru-mono-regular-oblique.woff2 +0 -0
  46. package/dist/fonts/gt-maru-mono-regular.woff2 +0 -0
  47. package/dist/fonts/gt-maru-regular-oblique.woff2 +0 -0
  48. package/dist/fonts/gt-maru-regular.woff2 +0 -0
  49. package/dist/fonts/maru/GT-Maru-Light-Oblique-Trial.woff2 +0 -0
  50. package/dist/fonts/maru/GT-Maru-Light-Trial.woff2 +0 -0
  51. package/dist/fonts/maru/GT-Maru-Medium-Oblique-Trial.woff2 +0 -0
  52. package/dist/fonts/maru/GT-Maru-Medium-Trial.woff2 +0 -0
  53. package/dist/fonts/maru/GT-Maru-Mono-Black-Oblique-Trial.woff2 +0 -0
  54. package/dist/fonts/maru/GT-Maru-Mono-Black-Trial.woff2 +0 -0
  55. package/dist/fonts/maru/GT-Maru-Mono-Bold-Oblique-Trial.woff2 +0 -0
  56. package/dist/fonts/maru/GT-Maru-Mono-Bold-Trial.woff2 +0 -0
  57. package/dist/fonts/maru/GT-Maru-Mono-Light-Oblique-Trial.woff2 +0 -0
  58. package/dist/fonts/maru/GT-Maru-Mono-Light-Trial.woff2 +0 -0
  59. package/dist/fonts/maru/GT-Maru-Mono-Medium-Oblique-Trial.woff2 +0 -0
  60. package/dist/fonts/maru/GT-Maru-Mono-Medium-Trial.woff2 +0 -0
  61. package/dist/fonts/maru/gt-maru-black-oblique.woff2 +0 -0
  62. package/dist/fonts/maru/gt-maru-black.woff2 +0 -0
  63. package/dist/fonts/maru/gt-maru-bold-oblique.woff2 +0 -0
  64. package/dist/fonts/maru/gt-maru-bold.woff2 +0 -0
  65. package/dist/fonts/maru/gt-maru-mega-l.woff2 +0 -0
  66. package/dist/fonts/maru/gt-maru-mega-m.woff2 +0 -0
  67. package/dist/fonts/maru/gt-maru-mega-s.woff2 +0 -0
  68. package/dist/fonts/maru/gt-maru-mono-regular-oblique.woff2 +0 -0
  69. package/dist/fonts/maru/gt-maru-mono-regular.woff2 +0 -0
  70. package/dist/fonts/maru/gt-maru-regular-oblique.woff2 +0 -0
  71. package/dist/fonts/maru/gt-maru-regular.woff2 +0 -0
  72. package/dist/gl-B5722hRa.js +3258 -0
  73. package/dist/gl-Bw-y_sGO.cjs +3262 -0
  74. package/dist/hooks.cjs +24 -0
  75. package/dist/hooks.d.ts +190 -0
  76. package/dist/hooks.js +1 -0
  77. package/dist/index-BeKLV88y.js +3910 -0
  78. package/dist/index-C4Yt_aL6.cjs +114199 -0
  79. package/dist/index-COnXZQL9.cjs +3912 -0
  80. package/dist/index-CQ90hVPI.js +113847 -0
  81. package/dist/index.cjs +343 -41240
  82. package/dist/index.d.ts +470 -354
  83. package/dist/index.js +4 -40894
  84. package/dist/server.cjs +0 -3
  85. package/dist/server.d.ts +0 -2
  86. package/dist/server.js +1 -3
  87. package/dist/styles.css +961 -647
  88. package/dist/svg-Bi5ULzxB.cjs +73 -0
  89. package/dist/svg-CoSCBw2u.js +65 -0
  90. package/dist/useWindowReady-CESjx5iD.cjs +9275 -0
  91. package/dist/useWindowReady-CIGrizO6.js +9185 -0
  92. package/dist/utils.cjs +39 -0
  93. package/dist/utils.d.ts +90 -0
  94. package/dist/utils.js +2 -0
  95. package/package.json +71 -70
  96. package/dist/gl-BytuN41l.cjs +0 -380
  97. package/dist/gl-D_Ly48gx.js +0 -357
@@ -1,357 +0,0 @@
1
- import loadFont from 'load-bmfont';
2
- import * as THREE$1 from 'three';
3
- import createGeometry from 'three-bmfont-text';
4
- import OrbitControls from 'three-orbit-controls';
5
-
6
- function getDefaultExportFromCjs (x) {
7
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
8
- }
9
-
10
- /*
11
- object-assign
12
- (c) Sindre Sorhus
13
- @license MIT
14
- */
15
-
16
- var objectAssign;
17
- var hasRequiredObjectAssign;
18
-
19
- function requireObjectAssign () {
20
- if (hasRequiredObjectAssign) return objectAssign;
21
- hasRequiredObjectAssign = 1;
22
- /* eslint-disable no-unused-vars */
23
- var getOwnPropertySymbols = Object.getOwnPropertySymbols;
24
- var hasOwnProperty = Object.prototype.hasOwnProperty;
25
- var propIsEnumerable = Object.prototype.propertyIsEnumerable;
26
-
27
- function toObject(val) {
28
- if (val === null || val === undefined) {
29
- throw new TypeError('Object.assign cannot be called with null or undefined');
30
- }
31
-
32
- return Object(val);
33
- }
34
-
35
- function shouldUseNative() {
36
- try {
37
- if (!Object.assign) {
38
- return false;
39
- }
40
-
41
- // Detect buggy property enumeration order in older V8 versions.
42
-
43
- // https://bugs.chromium.org/p/v8/issues/detail?id=4118
44
- var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
45
- test1[5] = 'de';
46
- if (Object.getOwnPropertyNames(test1)[0] === '5') {
47
- return false;
48
- }
49
-
50
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
51
- var test2 = {};
52
- for (var i = 0; i < 10; i++) {
53
- test2['_' + String.fromCharCode(i)] = i;
54
- }
55
- var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
56
- return test2[n];
57
- });
58
- if (order2.join('') !== '0123456789') {
59
- return false;
60
- }
61
-
62
- // https://bugs.chromium.org/p/v8/issues/detail?id=3056
63
- var test3 = {};
64
- 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
65
- test3[letter] = letter;
66
- });
67
- if (Object.keys(Object.assign({}, test3)).join('') !==
68
- 'abcdefghijklmnopqrst') {
69
- return false;
70
- }
71
-
72
- return true;
73
- } catch (err) {
74
- // We don't expect any of the above to throw, but better to be safe.
75
- return false;
76
- }
77
- }
78
-
79
- objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
80
- var from;
81
- var to = toObject(target);
82
- var symbols;
83
-
84
- for (var s = 1; s < arguments.length; s++) {
85
- from = Object(arguments[s]);
86
-
87
- for (var key in from) {
88
- if (hasOwnProperty.call(from, key)) {
89
- to[key] = from[key];
90
- }
91
- }
92
-
93
- if (getOwnPropertySymbols) {
94
- symbols = getOwnPropertySymbols(from);
95
- for (var i = 0; i < symbols.length; i++) {
96
- if (propIsEnumerable.call(from, symbols[i])) {
97
- to[symbols[i]] = from[symbols[i]];
98
- }
99
- }
100
- }
101
- }
102
-
103
- return to;
104
- };
105
- return objectAssign;
106
- }
107
-
108
- var msdf;
109
- var hasRequiredMsdf;
110
-
111
- function requireMsdf () {
112
- if (hasRequiredMsdf) return msdf;
113
- hasRequiredMsdf = 1;
114
- var assign = requireObjectAssign();
115
-
116
- msdf = function createMSDFShader (opt) {
117
- opt = opt || {};
118
- var opacity = typeof opt.opacity === 'number' ? opt.opacity : 1;
119
- var alphaTest = typeof opt.alphaTest === 'number' ? opt.alphaTest : 0.0001;
120
- var precision = opt.precision || 'highp';
121
- var color = opt.color;
122
- var map = opt.map;
123
- var negate = typeof opt.negate === 'boolean' ? opt.negate : true;
124
-
125
- // remove to satisfy r73
126
- delete opt.map;
127
- delete opt.color;
128
- delete opt.precision;
129
- delete opt.opacity;
130
- delete opt.negate;
131
-
132
- return assign({
133
- uniforms: {
134
- opacity: { type: 'f', value: opacity },
135
- map: { type: 't', value: map || new THREE.Texture() },
136
- color: { type: 'c', value: new THREE.Color(color) }
137
- },
138
- vertexShader: [
139
- 'attribute vec2 uv;',
140
- 'attribute vec4 position;',
141
- 'uniform mat4 projectionMatrix;',
142
- 'uniform mat4 modelViewMatrix;',
143
- 'varying vec2 vUv;',
144
- 'void main() {',
145
- 'vUv = uv;',
146
- 'gl_Position = projectionMatrix * modelViewMatrix * position;',
147
- '}'
148
- ].join('\n'),
149
- fragmentShader: [
150
- '#ifdef GL_OES_standard_derivatives',
151
- '#extension GL_OES_standard_derivatives : enable',
152
- '#endif',
153
- 'precision ' + precision + ' float;',
154
- 'uniform float opacity;',
155
- 'uniform vec3 color;',
156
- 'uniform sampler2D map;',
157
- 'varying vec2 vUv;',
158
-
159
- 'float median(float r, float g, float b) {',
160
- ' return max(min(r, g), min(max(r, g), b));',
161
- '}',
162
-
163
- 'void main() {',
164
- ' vec3 sample = ' + (negate ? '1.0 - ' : '') + 'texture2D(map, vUv).rgb;',
165
- ' float sigDist = median(sample.r, sample.g, sample.b) - 0.5;',
166
- ' float alpha = clamp(sigDist/fwidth(sigDist) + 0.5, 0.0, 1.0);',
167
- ' gl_FragColor = vec4(color.xyz, alpha * opacity);',
168
- alphaTest === 0
169
- ? ''
170
- : ' if (gl_FragColor.a < ' + alphaTest + ') discard;',
171
- '}'
172
- ].join('\n')
173
- }, opt);
174
- };
175
- return msdf;
176
- }
177
-
178
- var msdfExports = requireMsdf();
179
- const MSDFShader = /*@__PURE__*/getDefaultExportFromCjs(msdfExports);
180
-
181
- const vertexShader = `
182
- varying vec2 vUv;
183
- varying vec3 vPos;
184
-
185
- void main() {
186
- vUv = uv;
187
- vPos = position;
188
-
189
- gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.);
190
- }
191
- `;
192
- const fragmentShader = `
193
- varying vec2 vUv;
194
- varying vec3 vPos;
195
-
196
- uniform sampler2D uTexture;
197
- uniform float uTime;
198
-
199
- void main() {
200
- float time = uTime * 0.5;
201
- vec2 repeat = -vec2(12., 3.);
202
- // To repeat the uvs we need to multiply them by a scalar
203
- // and then get the fractional part of it so they from 0 to 1
204
- // To move them continuously we have to add time
205
- // to the x or y component, to change the direction
206
- vec2 uv = fract(vUv * repeat - vec2(time, 0.)); // The sign of time change direction of movement
207
-
208
- // Fake shadow
209
- float shadow = clamp(vPos.z / 5., 0., 1.);
210
-
211
- vec3 texture = texture2D(uTexture, uv).rgb;
212
- // texture *= vec3(uv.x, uv.y, 1.); // To help visualize the repeated uvs
213
-
214
- gl_FragColor = vec4(texture * shadow, 1.);
215
- }
216
- `;
217
-
218
- class GL {
219
- renderer;
220
- camera;
221
- scene;
222
- controls;
223
- clock;
224
- rt;
225
- rtCamera;
226
- rtScene;
227
- text;
228
- mesh;
229
- geometry;
230
- material;
231
- fontGeometry;
232
- fontMaterial;
233
- loader;
234
- rafId;
235
- isDestroyed = false;
236
- constructor() {
237
- this.renderer = new THREE$1.WebGLRenderer({
238
- alpha: true
239
- });
240
- this.renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.5));
241
- this.renderer.setSize(window.innerWidth, window.innerHeight);
242
- this.renderer.setClearColor(0, 1);
243
- document.body.appendChild(this.renderer.domElement);
244
- this.camera = new THREE$1.PerspectiveCamera(
245
- 45,
246
- window.innerWidth / window.innerHeight,
247
- 1,
248
- 1e3
249
- );
250
- this.camera.position.z = 60;
251
- this.scene = new THREE$1.Scene();
252
- this.controls = new (OrbitControls(THREE$1))(
253
- this.camera,
254
- this.renderer.domElement
255
- );
256
- this.clock = new THREE$1.Clock();
257
- }
258
- init() {
259
- loadFont("/fonts/orbitron/orbitron-black.fnt", (_, font) => {
260
- this.fontGeometry = createGeometry({
261
- font,
262
- text: "ENDLESS"
263
- });
264
- this.loader = new THREE$1.TextureLoader();
265
- this.loader.load("/fonts/orbitron/orbitron-black.png", (texture) => {
266
- this.fontMaterial = new THREE$1.RawShaderMaterial(
267
- MSDFShader({
268
- map: texture,
269
- side: THREE$1.DoubleSide,
270
- transparent: true,
271
- negate: false,
272
- color: 16777215
273
- })
274
- );
275
- this.createRenderTarget();
276
- this.createMesh();
277
- this.animate();
278
- this.addEvents();
279
- });
280
- });
281
- }
282
- createRenderTarget() {
283
- this.rt = new THREE$1.WebGLRenderTarget(window.innerWidth, window.innerHeight);
284
- this.rtCamera = new THREE$1.PerspectiveCamera(45, 1, 0.1, 1e3);
285
- this.rtCamera.position.z = 2.5;
286
- this.rtScene = new THREE$1.Scene();
287
- this.rtScene.background = new THREE$1.Color("#000000");
288
- this.text = new THREE$1.Mesh(this.fontGeometry, this.fontMaterial);
289
- this.text.position.set(-0.965, -0.525, 0);
290
- this.text.rotation.set(Math.PI, 0, 0);
291
- this.text.scale.set(8e-3, 0.04, 1);
292
- this.rtScene.add(this.text);
293
- }
294
- createMesh() {
295
- if (!this.rt) return;
296
- this.geometry = new THREE$1.TorusKnotGeometry(9, 3, 768, 3, 4, 3);
297
- this.material = new THREE$1.ShaderMaterial({
298
- vertexShader,
299
- fragmentShader,
300
- uniforms: {
301
- uTime: { value: 0 },
302
- uTexture: { value: this.rt.texture }
303
- }
304
- });
305
- this.mesh = new THREE$1.Mesh(this.geometry, this.material);
306
- this.scene.add(this.mesh);
307
- }
308
- animate() {
309
- if (this.isDestroyed) return;
310
- this.rafId = requestAnimationFrame(this.animate.bind(this));
311
- this.render();
312
- }
313
- render() {
314
- if (!this.material || !this.rt || !this.rtScene || !this.rtCamera) return;
315
- this.controls.update();
316
- this.material.uniforms.uTime.value = this.clock.getElapsedTime();
317
- this.renderer.setRenderTarget(this.rt);
318
- this.renderer.render(this.rtScene, this.rtCamera);
319
- this.renderer.setRenderTarget(null);
320
- this.renderer.render(this.scene, this.camera);
321
- }
322
- addEvents() {
323
- window.addEventListener("resize", this.resize.bind(this));
324
- }
325
- resize() {
326
- const width = window.innerWidth;
327
- const height = window.innerHeight;
328
- this.camera.aspect = width / height;
329
- this.camera.updateProjectionMatrix();
330
- this.renderer.setSize(width, height);
331
- }
332
- destroy() {
333
- this.isDestroyed = true;
334
- if (this.rafId) {
335
- cancelAnimationFrame(this.rafId);
336
- this.rafId = void 0;
337
- }
338
- if (this.geometry) {
339
- this.geometry.dispose();
340
- }
341
- if (this.material) {
342
- this.material.dispose();
343
- }
344
- if (this.fontMaterial) {
345
- this.fontMaterial.dispose();
346
- }
347
- if (this.rt) {
348
- this.rt.dispose();
349
- }
350
- if (this.renderer) {
351
- this.renderer.dispose();
352
- }
353
- window.removeEventListener("resize", this.resize.bind(this));
354
- }
355
- }
356
-
357
- export { GL };