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