Skip to content
This repository was archived by the owner on Dec 21, 2025. It is now read-only.

Commit 3b56f7c

Browse files
committed
FIX/Patterns.js: ensure proper start (>= 0 instead of > 0)
+ Several code cleanups
1 parent 91bb8ba commit 3b56f7c

6 files changed

Lines changed: 30 additions & 66 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "artwork.running-patterns",
3-
"version": "0.0.9",
3+
"version": "0.0.10",
44
"description": "Running Patterns/Laufende Muster artwork for the vi.son - mixing-senses project",
55
"main": "src/js/index.js",
66
"scripts": {

src/js/artwork/ArtworkContainer.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/js/artwork/Patterns.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -741,23 +741,32 @@ class Patterns {
741741
if (patternsLogic.values.state === PATTERNS_STATES.BEZIER_SETUP) {
742742
// Update bezier
743743
const { x, y, z } = this._startHandle.position;
744-
this._startHandleLine.geometry.attributes.position.array[0] = this._startSphere.position.x;
745-
this._startHandleLine.geometry.attributes.position.array[1] = this._startSphere.position.y;
746-
this._startHandleLine.geometry.attributes.position.array[2] = this._startSphere.position.z;
744+
this._startHandleLine.geometry.attributes.position.array[0] =
745+
this._startSphere.position.x;
746+
this._startHandleLine.geometry.attributes.position.array[1] =
747+
this._startSphere.position.y;
748+
this._startHandleLine.geometry.attributes.position.array[2] =
749+
this._startSphere.position.z;
747750

748751
this._startHandleLine.geometry.attributes.position.array[3] = x;
749752
this._startHandleLine.geometry.attributes.position.array[4] = y;
750753
this._startHandleLine.geometry.attributes.position.array[5] = z;
751754

752755
this._startHandleLine.geometry.attributes.position.needsUpdate = true;
753756

754-
this._endHandleLine.geometry.attributes.position.array[0] = this._endSphere.position.x;
755-
this._endHandleLine.geometry.attributes.position.array[1] = this._endSphere.position.y;
756-
this._endHandleLine.geometry.attributes.position.array[2] = this._endSphere.position.z;
757-
758-
this._endHandleLine.geometry.attributes.position.array[3] = this._endHandle.position.x;
759-
this._endHandleLine.geometry.attributes.position.array[4] = this._endHandle.position.y;
760-
this._endHandleLine.geometry.attributes.position.array[5] = this._endHandle.position.z;
757+
this._endHandleLine.geometry.attributes.position.array[0] =
758+
this._endSphere.position.x;
759+
this._endHandleLine.geometry.attributes.position.array[1] =
760+
this._endSphere.position.y;
761+
this._endHandleLine.geometry.attributes.position.array[2] =
762+
this._endSphere.position.z;
763+
764+
this._endHandleLine.geometry.attributes.position.array[3] =
765+
this._endHandle.position.x;
766+
this._endHandleLine.geometry.attributes.position.array[4] =
767+
this._endHandle.position.y;
768+
this._endHandleLine.geometry.attributes.position.array[5] =
769+
this._endHandle.position.z;
761770
this._endHandleLine.geometry.attributes.position.needsUpdate = true;
762771
}
763772

@@ -803,7 +812,7 @@ class Patterns {
803812
if (this._stats !== undefined) {
804813
this._stats.update();
805814
}
806-
if (this._audioPlayProgress <= 1.0 && this._audioStartedAt > 0) {
815+
if (this._audioPlayProgress <= 1.0 && this._audioStartedAt >= 0) {
807816
patternsLogic.actions.updatePlayProgress(this._audioPlayProgress);
808817
this._$f++;
809818
}

src/js/artwork/PatternsTrack.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ class PatternsTrack extends THREE.Group {
2020
threshold
2121
) {
2222
super();
23-
23+
this.setupAudio(audioListener);
2424
this._colorChannel = colorChannel;
2525
this._yOffset = yOffset;
2626
this._color = color;
2727
this._index = index;
2828
this._trackName = name;
2929
this._threshold = threshold;
30-
3130
this._material = new THREE.ShaderMaterial({
3231
vertexShader: patternVS,
3332
fragmentShader: patternFS,
@@ -64,11 +63,9 @@ class PatternsTrack extends THREE.Group {
6463
console.log("Y offset", this._yOffset);
6564
console.log("Color", this._color);
6665
console.groupEnd();
67-
68-
this._setupAudio(audioListener);
6966
}
7067

71-
_setupAudio(audioListener) {
68+
setupAudio(audioListener) {
7269
this._audio = new THREE.Audio(audioListener);
7370
this._analyzer = new THREE.AudioAnalyser(this._audio, 32);
7471
}
@@ -239,9 +236,8 @@ class PatternsTrack extends THREE.Group {
239236
);
240237
geometries.push(instanceGeometry);
241238
}
242-
const patternsGeometry = BufferGeometryUtils.mergeBufferGeometries(
243-
geometries
244-
);
239+
const patternsGeometry =
240+
BufferGeometryUtils.mergeBufferGeometries(geometries);
245241
this._instanceMesh = new THREE.Mesh(patternsGeometry, this._material);
246242
return this._instanceMesh;
247243
}

src/js/artwork/PatternsUI.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ const PatternsUI = ({ paused }) => {
2929
}, []);
3030

3131
useEffect(() => {
32-
if (artwork && paused) {
32+
if (artwork === null) return;
33+
if (paused) {
3334
artwork.pause();
3435
}
35-
if (artwork && !paused) {
36+
if (!paused) {
3637
artwork.continue();
3738
}
3839
}, [paused]);

src/js/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { ButtonCloseNarrative } from "@vi.son/components";
1212
import { ButtonEmoji } from "@vi.son/components";
1313
import { ButtonOpenNarrative } from "@vi.son/components";
1414
import { ButtonToExhibition } from "@vi.son/components";
15-
import ArtworkContainer from "./artwork/ArtworkContainer.js";
1615
import PatternsUI from "./artwork/PatternsUI.js";
1716
import Intro from "./artwork/Intro.js";
1817
import TrackUserInterface from "./artwork/TrackUserInterface.js";
@@ -37,10 +36,8 @@ const Artwork = () => {
3736
const [content, setContent] = useState({});
3837
const [isFullscreen, setIsFullscreen] = useState(false);
3938

40-
const { state, patternTracks, volumes } = useValues(patternsLogic);
41-
const { setState, updatePatternTrack, updateVolume } = useActions(
42-
patternsLogic
43-
);
39+
const { state, patternTracks } = useValues(patternsLogic);
40+
const { setState } = useActions(patternsLogic);
4441

4542
const isMobile = mobileCheck();
4643

@@ -77,7 +74,6 @@ const Artwork = () => {
7774
<h1 className="state">{state}</h1>
7875
)}
7976
<PatternsUI paused={showNarrative} />
80-
{/* <ArtworkContainer /> */}
8177
</div>
8278
}
8379
content={

0 commit comments

Comments
 (0)