Skip to content

Commit 9cdc20b

Browse files
committed
update dotproduct
1 parent e51bd38 commit 9cdc20b

File tree

15 files changed

+1614
-23
lines changed

15 files changed

+1614
-23
lines changed

apps/threejs-project/src/scene.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
import './style.css';
2+
23
import { assert } from '@cutting/assert';
34
import {
4-
Scene,
5-
WebGLRenderer,
6-
MeshBasicMaterial,
7-
Mesh,
8-
LineBasicMaterial,
9-
Vector3,
105
ArrowHelper,
116
BufferGeometry,
127
Line,
8+
LineBasicMaterial,
9+
Mesh,
10+
MeshBasicMaterial,
1311
OrthographicCamera,
12+
Scene,
13+
Vector3,
14+
WebGLRenderer,
1415
} from 'three';
15-
import { addTick } from './utils/addTick';
16-
import { addAxis } from './utils/addAxis';
17-
import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js';
16+
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
1817
import { TextGeometry } from 'three/examples/jsm/geometries/TextGeometry.js';
18+
import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js';
19+
1920
import { axes } from './types';
20-
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
21+
import { addTick } from './utils/addTick';
22+
import { addCylinderLine } from './utils/lines';
2123

2224
const AxisLength = 3;
2325

@@ -28,9 +30,9 @@ function run() {
2830

2931
const scene = new Scene();
3032

31-
addAxis(scene, new Vector3(-AxisLength, 0, 0), new Vector3(AxisLength, 0, 0));
32-
addAxis(scene, new Vector3(0, -AxisLength, 0), new Vector3(0, AxisLength, 0));
33-
addAxis(scene, new Vector3(0, 0, -AxisLength), new Vector3(0, 0, AxisLength));
33+
addCylinderLine(scene, new Vector3(-AxisLength, 0, 0), new Vector3(AxisLength, 0, 0));
34+
addCylinderLine(scene, new Vector3(0, -AxisLength, 0), new Vector3(0, AxisLength, 0));
35+
addCylinderLine(scene, new Vector3(0, 0, -AxisLength), new Vector3(0, 0, AxisLength));
3436

3537
const tickPositions = [-3, -2, -1, 0, 1, 2, 3];
3638

@@ -147,9 +149,9 @@ function run() {
147149
scene.add(line);
148150
}
149151

150-
addAxis(scene, new Vector3(0, 0, 0), new Vector3(2, 2, 2), 0xff0000);
152+
addCylinderLine(scene, new Vector3(0, 0, 0), new Vector3(2, 2, 2), 0xff0000);
151153

152-
addAxis(scene, new Vector3(0, 0, 0), new Vector3(1, 0, 1), 0x0000ff);
154+
addCylinderLine(scene, new Vector3(0, 0, 0), new Vector3(1, 0, 1), 0x0000ff);
153155

154156
const sizes = {
155157
width: window.innerWidth,
@@ -168,16 +170,16 @@ function run() {
168170

169171
const frustumSize = 8;
170172
const aspect = sizes.width / sizes.height;
171-
173+
172174
const camera = new OrthographicCamera(
173-
-aspect * frustumSize / 2,
174-
aspect * frustumSize / 2,
175+
(-aspect * frustumSize) / 2,
176+
(aspect * frustumSize) / 2,
175177
frustumSize / 2,
176178
-frustumSize / 2,
177179
0.1,
178180
100,
179181
);
180-
camera.position.set(5, 5, 5);
182+
camera.position.set(2, 2, 6);
181183
camera.lookAt(0, 0, 0);
182184

183185
const renderer = new WebGLRenderer({
@@ -202,4 +204,4 @@ function run() {
202204
tick();
203205
}
204206

205-
run();
207+
run();

apps/threejs-project/src/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
body {
1818
margin: 0;
1919
padding: 0;
20+
background-color: #000000;
2021
}
2122

2223
body,
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import type { ColorRepresentation, Scene } from 'three';
22
import { CylinderGeometry, Mesh, MeshBasicMaterial, Vector3 } from 'three';
33

4-
export function addAxis(scene: Scene, start: Vector3, end: Vector3, color: ColorRepresentation = 0x000000): void {
4+
export function addCylinderLine(
5+
scene: Scene,
6+
start: Vector3,
7+
end: Vector3,
8+
color: ColorRepresentation = 0x000000,
9+
): void {
510
const direction = new Vector3().subVectors(end, start);
611
const length = direction.length();
712
const cylinderGeometry = new CylinderGeometry(0.02, 0.02, length, 8);

apps/website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
"referrer-policy": "1.2.0",
7171
"regression": "2.0.1",
7272
"serve-static": "2.2.0",
73+
"three": "^0.175.0",
7374
"ts-pattern": "5.7.0",
7475
"url-join": "5.0.0"
7576
},

apps/website/public/fonts/LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright � 2004 by MAGENTA Ltd. All Rights Reserved.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of the fonts accompanying this license ("Fonts") and associated documentation files (the "Font Software"), to reproduce and distribute the Font Software, including without limitation the rights to use, copy, merge, publish, distribute, and/or sell copies of the Font Software, and to permit persons to whom the Font Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright and this permission notice shall be included in all copies of one or more of the Font Software typefaces.
6+
7+
The Font Software may be modified, altered, or added to, and in particular the designs of glyphs or characters in the Fonts may be modified and additional glyphs or characters may be added to the Fonts, only if the fonts are renamed to names not containing the word "MgOpen", or if the modifications are accepted for inclusion in the Font Software itself by the each appointed Administrator.
8+
9+
This License becomes null and void to the extent applicable to Fonts or Font Software that has been modified and is distributed under the "MgOpen" name.
10+
11+
The Font Software may be sold as part of a larger software package but no copy of one or more of the Font Software typefaces may be sold by itself.
12+
13+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL MAGENTA OR PERSONS OR BODIES IN CHARGE OF ADMINISTRATION AND MAINTENANCE OF THE FONT SOFTWARE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.

0 commit comments

Comments
 (0)