constructor(config) {
super(config);
- this.lineLength = this.lineLength || 1000;
+ this.lineLength = this.lineLength || 500;
}
};
entity.addComponent(new EulerAngle());
entity.addComponent(new Velocity({
x: 0,
- y: Math.PI / 180,
+ y: Math.PI / 30,
z: 0,
}));
entity.addComponent(new Radius({
export function settingsContainer({id, label, level=2}) {
- const container = document.createElement('div');
+ const container = document.createElement('section');
container.id = id;
container.innerHTML = `<h${level}>${label}</h${level}>`;
return container;
};
-export function slider({min, max, step, get, set, label = '', className}) {
+export function slider({
+ id,
+ min,
+ max,
+ step,
+ shiftStep,
+ get,
+ set,
+ label = '',
+ className
+}) {
- const sliderContainer = document.createElement('div');
+ const sliderContainer = document.createElement('section');
sliderContainer.classList.add('slider');
sliderContainer.classList.add(className);
const labelElement = document.createElement('label');
+ labelElement.setAttribute('for', id);
labelElement.innerHTML = label;
const slider = document.createElement('input');
+ slider.id = id;
slider.type = 'range';
slider.min = min;
slider.max = max;
slider.step = step;
slider.value = get().toString();
+ if (shiftStep) {
+ document.addEventListener('keydown', function(event) {
+ if (event.shiftKey) {
+ slider.classList.add('shifted');
+ slider.step = shiftStep;
+ }
+ });
+
+ document.addEventListener('keyup', function(event) {
+ if (event.key === 'Shift') {
+ slider.classList.remove('shifted');
+ slider.step = step;
+ }
+ });
+ }
+
slider.addEventListener('input', () => set(slider.value));
sliderContainer.appendChild(labelElement);
['a', 'b', 'c'].forEach(key => {
nodeElement.appendChild(slider({
+ id: `amplitude-adjuster-${i}-slider-${key}`,
min: '0',
max: '1',
step: '0.01',
});
nodeElement.appendChild(slider({
+ id: `camera-adjuster-${i}-slider-radius`,
min: '2',
max: '10',
step: '0.1',
['x', 'y', 'z'].forEach(key => {
nodeElement.appendChild(slider({
+ id: `camera-adjuster-${i}-slider-${key}`,
min: '0',
max: '0.5',
step: '0.001',
camera.up.y = up[1];
camera.up.z = up[2];
- camera.angle.pitch = (camera.angle.pitch + camera.velocity.x * dt / 100 + 2 * Math.PI) % (2 * Math.PI);
- camera.angle.yaw = (camera.angle.yaw + camera.velocity.y * dt / 100 + 2 * Math.PI) % (2 * Math.PI);
- camera.angle.roll = (camera.angle.roll + camera.velocity.z * dt / 100 + 2 * Math.PI) % (2 * Math.PI);
+ camera.angle.pitch = (camera.angle.pitch + camera.velocity.x * dt / 500 + 2 * Math.PI) % (2 * Math.PI);
+ camera.angle.yaw = (camera.angle.yaw + camera.velocity.y * dt / 500 + 2 * Math.PI) % (2 * Math.PI);
+ camera.angle.roll = (camera.angle.roll + camera.velocity.z * dt / 500 + 2 * Math.PI) % (2 * Math.PI);
}
}
};
['a', 'b', 'c'].forEach(key => {
nodeElement.appendChild(slider({
+ id: `frequency-adjuster-${i}-slider-${key}`,
min: '0',
- max: '1',
- step: '0.01',
+ max: (2 * Math.PI).toString(),
+ step: '0.05',
+ shiftStep: (Math.PI / 8).toString(),
label: internals.symbols[key],
className: `frequency`,
get: () => node.frequency[key].toString(),
});
nodeElement.appendChild(slider({
+ id: `global-adjuster-${i}-slider`,
min: '5',
- max: '2000',
- step: '1',
+ max: '1000',
+ step: '5',
label: '𝜆',
className: 'lineLength',
get: () => node.configuration.lineLength.toString(),
update(dt){
- this.time = (this.time + dt / 100) % internals.kPeriod;
+ this.time = (this.time + dt / 500) % internals.kPeriod;
for (const curve of this.curves) {
curve.position.x = this._getPosition(curve.amplitude.a, curve.frequency.a, this.time, 0);
"@serpentity/components.euler_angle": "^4.0.0",
"@serpentity/components.position": "^4.0.1",
"@serpentity/components.velocity": "^4.0.3",
- "@serpentity/serpentity": "^4.0.0",
+ "@serpentity/serpentity": "^4.1.0",
"gl-matrix": "3.4.0"
}
}
dependencies:
'@serpentity/components.euler_angle':
specifier: ^4.0.0
- version: 4.0.0(@serpentity/serpentity@4.0.0)
+ version: 4.0.0(@serpentity/serpentity@4.1.0)
'@serpentity/components.position':
specifier: ^4.0.1
- version: 4.0.1(@serpentity/serpentity@4.0.0)
+ version: 4.0.1(@serpentity/serpentity@4.1.0)
'@serpentity/components.velocity':
specifier: ^4.0.3
- version: 4.0.3(@serpentity/serpentity@4.0.0)
+ version: 4.0.3(@serpentity/serpentity@4.1.0)
'@serpentity/serpentity':
- specifier: ^4.0.0
- version: 4.0.0
+ specifier: ^4.1.0
+ version: 4.1.0
gl-matrix:
specifier: 3.4.0
version: 3.4.0
dev: true
optional: true
- /@serpentity/components.euler_angle@4.0.0(@serpentity/serpentity@4.0.0):
+ /@serpentity/components.euler_angle@4.0.0(@serpentity/serpentity@4.1.0):
resolution: {integrity: sha512-DoWghww9eEBanuHAPlVtBGeGyIS2wQu/M90iChdMTHUWR9uITAWbFT1aFQmRyY++7lxUbAdrusizeQ6XlQIw8Q==}
peerDependencies:
'@serpentity/serpentity': ^4.0.0
dependencies:
- '@serpentity/serpentity': 4.0.0
+ '@serpentity/serpentity': 4.1.0
dev: false
- /@serpentity/components.position@4.0.1(@serpentity/serpentity@4.0.0):
+ /@serpentity/components.position@4.0.1(@serpentity/serpentity@4.1.0):
resolution: {integrity: sha512-G2Q9huGgf7R61Lxx6ly+fYMfHBO5O+AvcDAJM0dENM3vmJl6lj8KZHNcIEOk+Vre+fTjWNX/aiNDphK9sDnAYA==}
peerDependencies:
'@serpentity/serpentity': ^4.0.0
dependencies:
- '@serpentity/serpentity': 4.0.0
+ '@serpentity/serpentity': 4.1.0
dev: false
- /@serpentity/components.velocity@4.0.3(@serpentity/serpentity@4.0.0):
+ /@serpentity/components.velocity@4.0.3(@serpentity/serpentity@4.1.0):
resolution: {integrity: sha512-bPQf6Yz8gjraS2SNQquqsfopPnl1QtHjVz52om4CZ7gRqrFQzawsxs98I74/MtGjW3LAK4LSQyrPujy85j188g==}
peerDependencies:
'@serpentity/serpentity': ^4.0.0
dependencies:
- '@serpentity/serpentity': 4.0.0
+ '@serpentity/serpentity': 4.1.0
dev: false
- /@serpentity/serpentity@4.0.0:
- resolution: {integrity: sha512-RlsG5lMFvho/15LW9SJ5uFcb8WjAH7uZaToTJPRJEzAUntMnyQxZpPl7ensAHjbuBasBkgg7IDipl5GBuf6S0Q==}
+ /@serpentity/serpentity@4.1.0:
+ resolution: {integrity: sha512-1G2hLUSeCMLqIebm/GCJAj+xJRerrSSBRU7cbdOrYRl3gDqpTcfz6ndhBQlQpLdn+8nyC3enRKWdcZPWj4OZfA==}
engines: {node: '>= 20.0.0'}
dev: false
}
input[type="range"]::-moz-range-thumb {
+ -webkit-appearance: none;
height: 16px;
width: 16px;
background-color: #80FFCC;
border-radius: 50%;
}
+input.shifted[type="range"]::-moz-range-thumb {
+ background-color: #FFB4F0;
+}
+
+input.shifted[type="range"]::-webkit-slider-thumb {
+ background-color: #FFB4F0;
+}
+
+input[type="range"]:focus::-moz-range-thumb {
+ background-color: #FF616B;
+}
+
+input[type="range"]:focus::-webkit-slider-thumb {
+ background-color: #FF616B;
+}
.slider::before,
.slider::after {