scax-engine 0.1.3 → 0.1.4
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.
- package/README.md +4 -5
- package/dist/scax-engine.cjs +14 -16
- package/dist/scax-engine.js +14 -16
- package/dist/scax-engine.umd.js +14 -16
- package/dist/types/scax-engine.d.ts +2 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# scax-engine
|
|
2
2
|
|
|
3
|
-
눈 모델(Gullstrand / Navarro)에 대한 광선 추적, Sturm 간격 분석,
|
|
3
|
+
눈 모델(Gullstrand / Navarro)에 대한 광선 추적, Sturm 간격 분석, 유발 난시·프리즘 편위 계산을 제공하는 TypeScript 안경광학 시뮬레이션(단안 기준, OD) 라이브러리입니다. ESM, CJS, UMD 빌드를 지원합니다.
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
English documentation: [README-en.md](README-en.md)
|
|
@@ -69,7 +69,7 @@ const next = engine.simulate();
|
|
|
69
69
|
|
|
70
70
|
### `new SCAXEngine(props?)`
|
|
71
71
|
|
|
72
|
-
시뮬레이션 엔진 인스턴스를 생성합니다. 내부 `Sturm
|
|
72
|
+
시뮬레이션 엔진 인스턴스를 생성합니다. 내부 `Sturm` 헬퍼는 인스턴스당 한 번만 생성됩니다.
|
|
73
73
|
|
|
74
74
|
#### `props`
|
|
75
75
|
|
|
@@ -103,13 +103,13 @@ const next = engine.simulate();
|
|
|
103
103
|
|
|
104
104
|
생성자와 동일한 설정 경로를 다시 실행합니다. `props`를 기준으로 eye / lens / 표면 / 광원을 재구성하며, 생략된 키에는 위 기본값이 적용됩니다.
|
|
105
105
|
|
|
106
|
-
- `Sturm
|
|
106
|
+
- `Sturm` 인스턴스는 재생성되지 않지만, `update` 직후에는 Sturm 분석 캐시가 비워지며 `simulate` 등으로 다시 채워집니다.
|
|
107
107
|
|
|
108
108
|
### `engine.dispose()`
|
|
109
109
|
|
|
110
110
|
엔진 인스턴스가 잡고 있던 추적/분석 캐시와 표면 trace history를 정리합니다.
|
|
111
111
|
|
|
112
|
-
- 해제 대상: traced rays, Sturm
|
|
112
|
+
- 해제 대상: traced rays, Sturm 캐시, surface incident/refracted history
|
|
113
113
|
- UI에서 엔진을 자주 새로 만들 때(예: 프레임별/슬라이더 연속 갱신) 이전 인스턴스에 `dispose()`를 호출하면 메모리 사용량을 안정적으로 유지할 수 있습니다.
|
|
114
114
|
|
|
115
115
|
### 인스턴스 메서드
|
|
@@ -152,7 +152,6 @@ const next = engine.simulate();
|
|
|
152
152
|
|
|
153
153
|
- `sturmCalculation(rays?)` — 추적 광선(인자 생략 시 마지막 `rayTracing`/`simulate` 결과)으로 Sturm 슬라이스·스펙트럼선별 분석 객체를 계산해 반환합니다. `simulate()` 호출 시 내부에서 Sturm도 갱신됩니다.
|
|
154
154
|
|
|
155
|
-
- `getAffineAnalysis()` — 현재 설정으로 망막 대응점 쌍을 만들어 아핀 적합을 수행(또는 캐시 재사용)합니다. 유효한 쌍이 부족하면 `null`이 될 수 있습니다.
|
|
156
155
|
|
|
157
156
|
## UMD
|
|
158
157
|
|
package/dist/scax-engine.cjs
CHANGED
|
@@ -8932,7 +8932,7 @@ const TABOToDeg = (TABOAngle) => {
|
|
|
8932
8932
|
* legacy simulator.js를 TypeScript로 옮긴 핵심 시뮬레이터입니다.
|
|
8933
8933
|
* - 광원 광선을 생성하고
|
|
8934
8934
|
* - 표면들을 순서대로 통과시키며 굴절을 계산한 뒤
|
|
8935
|
-
* -
|
|
8935
|
+
* - Sturm 분석까지 제공합니다.
|
|
8936
8936
|
*/
|
|
8937
8937
|
class SCAXEngineCore {
|
|
8938
8938
|
constructor(props = {}) {
|
|
@@ -9265,27 +9265,18 @@ class SCAXEngineCore {
|
|
|
9265
9265
|
this.lastSturmGapAnalysis = this.sturm.calculate(rays, this.effectiveCylinderFromOpticSurfaces(), this.lastSourceRaysForSturm, this.sturmEyeProfileWorldZBounds() ?? null);
|
|
9266
9266
|
return this.lastSturmGapAnalysis;
|
|
9267
9267
|
}
|
|
9268
|
-
/**
|
|
9269
|
-
* 3) Affine 왜곡 추정 전용 함수
|
|
9270
|
-
* 광선 대응쌍(sx,sy)->(tx,ty)에 대해 최소자승 2D affine을 적합합니다.
|
|
9271
|
-
*/
|
|
9272
|
-
estimateAffineDistortion(pairs) {
|
|
9273
|
-
const inputPairs = Array.isArray(pairs) ? pairs : [];
|
|
9274
|
-
this.lastAffineAnalysis = this.affine.estimate(inputPairs);
|
|
9275
|
-
return this.lastAffineAnalysis;
|
|
9276
|
-
}
|
|
9277
|
-
/**
|
|
9278
|
-
* 현재 eye+lens 설정 기준 affine 왜곡 결과를 반환합니다.
|
|
9279
|
-
* traced ray/affine 결과는 기존 계산값을 우선 재사용합니다.
|
|
9280
|
-
*/
|
|
9281
9268
|
getAffineAnalysis() {
|
|
9269
|
+
/*
|
|
9282
9270
|
if (!this.tracedRays.length) {
|
|
9283
|
-
|
|
9271
|
+
this.simulate();
|
|
9284
9272
|
}
|
|
9285
9273
|
if (!this.lastAffineAnalysis) {
|
|
9286
|
-
|
|
9274
|
+
this.lastAffineAnalysis = this.estimateAffineDistortion(this.createAffinePairs(this.tracedRays));
|
|
9287
9275
|
}
|
|
9288
9276
|
return this.lastAffineAnalysis;
|
|
9277
|
+
*/
|
|
9278
|
+
// Affine analysis is intentionally disabled for now.
|
|
9279
|
+
return null;
|
|
9289
9280
|
}
|
|
9290
9281
|
surfaceOrderZ(surface) {
|
|
9291
9282
|
const z = Number(this.readSurfacePosition(surface)?.z);
|
|
@@ -9537,6 +9528,13 @@ class SCAXEngineCore {
|
|
|
9537
9528
|
}
|
|
9538
9529
|
return 2 * Math.hypot(j0, j45);
|
|
9539
9530
|
}
|
|
9531
|
+
// Kept for later review/release.
|
|
9532
|
+
estimateAffineDistortion(pairs) {
|
|
9533
|
+
const inputPairs = Array.isArray(pairs) ? pairs : [];
|
|
9534
|
+
this.lastAffineAnalysis = this.affine.estimate(inputPairs);
|
|
9535
|
+
return this.lastAffineAnalysis;
|
|
9536
|
+
}
|
|
9537
|
+
// Kept for later review/release.
|
|
9540
9538
|
createAffinePairs(rays) {
|
|
9541
9539
|
return (Array.isArray(rays) ? rays : [])
|
|
9542
9540
|
.map((ray) => {
|
package/dist/scax-engine.js
CHANGED
|
@@ -8930,7 +8930,7 @@ const TABOToDeg = (TABOAngle) => {
|
|
|
8930
8930
|
* legacy simulator.js를 TypeScript로 옮긴 핵심 시뮬레이터입니다.
|
|
8931
8931
|
* - 광원 광선을 생성하고
|
|
8932
8932
|
* - 표면들을 순서대로 통과시키며 굴절을 계산한 뒤
|
|
8933
|
-
* -
|
|
8933
|
+
* - Sturm 분석까지 제공합니다.
|
|
8934
8934
|
*/
|
|
8935
8935
|
class SCAXEngineCore {
|
|
8936
8936
|
constructor(props = {}) {
|
|
@@ -9263,27 +9263,18 @@ class SCAXEngineCore {
|
|
|
9263
9263
|
this.lastSturmGapAnalysis = this.sturm.calculate(rays, this.effectiveCylinderFromOpticSurfaces(), this.lastSourceRaysForSturm, this.sturmEyeProfileWorldZBounds() ?? null);
|
|
9264
9264
|
return this.lastSturmGapAnalysis;
|
|
9265
9265
|
}
|
|
9266
|
-
/**
|
|
9267
|
-
* 3) Affine 왜곡 추정 전용 함수
|
|
9268
|
-
* 광선 대응쌍(sx,sy)->(tx,ty)에 대해 최소자승 2D affine을 적합합니다.
|
|
9269
|
-
*/
|
|
9270
|
-
estimateAffineDistortion(pairs) {
|
|
9271
|
-
const inputPairs = Array.isArray(pairs) ? pairs : [];
|
|
9272
|
-
this.lastAffineAnalysis = this.affine.estimate(inputPairs);
|
|
9273
|
-
return this.lastAffineAnalysis;
|
|
9274
|
-
}
|
|
9275
|
-
/**
|
|
9276
|
-
* 현재 eye+lens 설정 기준 affine 왜곡 결과를 반환합니다.
|
|
9277
|
-
* traced ray/affine 결과는 기존 계산값을 우선 재사용합니다.
|
|
9278
|
-
*/
|
|
9279
9266
|
getAffineAnalysis() {
|
|
9267
|
+
/*
|
|
9280
9268
|
if (!this.tracedRays.length) {
|
|
9281
|
-
|
|
9269
|
+
this.simulate();
|
|
9282
9270
|
}
|
|
9283
9271
|
if (!this.lastAffineAnalysis) {
|
|
9284
|
-
|
|
9272
|
+
this.lastAffineAnalysis = this.estimateAffineDistortion(this.createAffinePairs(this.tracedRays));
|
|
9285
9273
|
}
|
|
9286
9274
|
return this.lastAffineAnalysis;
|
|
9275
|
+
*/
|
|
9276
|
+
// Affine analysis is intentionally disabled for now.
|
|
9277
|
+
return null;
|
|
9287
9278
|
}
|
|
9288
9279
|
surfaceOrderZ(surface) {
|
|
9289
9280
|
const z = Number(this.readSurfacePosition(surface)?.z);
|
|
@@ -9535,6 +9526,13 @@ class SCAXEngineCore {
|
|
|
9535
9526
|
}
|
|
9536
9527
|
return 2 * Math.hypot(j0, j45);
|
|
9537
9528
|
}
|
|
9529
|
+
// Kept for later review/release.
|
|
9530
|
+
estimateAffineDistortion(pairs) {
|
|
9531
|
+
const inputPairs = Array.isArray(pairs) ? pairs : [];
|
|
9532
|
+
this.lastAffineAnalysis = this.affine.estimate(inputPairs);
|
|
9533
|
+
return this.lastAffineAnalysis;
|
|
9534
|
+
}
|
|
9535
|
+
// Kept for later review/release.
|
|
9538
9536
|
createAffinePairs(rays) {
|
|
9539
9537
|
return (Array.isArray(rays) ? rays : [])
|
|
9540
9538
|
.map((ray) => {
|
package/dist/scax-engine.umd.js
CHANGED
|
@@ -8936,7 +8936,7 @@
|
|
|
8936
8936
|
* legacy simulator.js를 TypeScript로 옮긴 핵심 시뮬레이터입니다.
|
|
8937
8937
|
* - 광원 광선을 생성하고
|
|
8938
8938
|
* - 표면들을 순서대로 통과시키며 굴절을 계산한 뒤
|
|
8939
|
-
* -
|
|
8939
|
+
* - Sturm 분석까지 제공합니다.
|
|
8940
8940
|
*/
|
|
8941
8941
|
class SCAXEngineCore {
|
|
8942
8942
|
constructor(props = {}) {
|
|
@@ -9269,27 +9269,18 @@
|
|
|
9269
9269
|
this.lastSturmGapAnalysis = this.sturm.calculate(rays, this.effectiveCylinderFromOpticSurfaces(), this.lastSourceRaysForSturm, this.sturmEyeProfileWorldZBounds() ?? null);
|
|
9270
9270
|
return this.lastSturmGapAnalysis;
|
|
9271
9271
|
}
|
|
9272
|
-
/**
|
|
9273
|
-
* 3) Affine 왜곡 추정 전용 함수
|
|
9274
|
-
* 광선 대응쌍(sx,sy)->(tx,ty)에 대해 최소자승 2D affine을 적합합니다.
|
|
9275
|
-
*/
|
|
9276
|
-
estimateAffineDistortion(pairs) {
|
|
9277
|
-
const inputPairs = Array.isArray(pairs) ? pairs : [];
|
|
9278
|
-
this.lastAffineAnalysis = this.affine.estimate(inputPairs);
|
|
9279
|
-
return this.lastAffineAnalysis;
|
|
9280
|
-
}
|
|
9281
|
-
/**
|
|
9282
|
-
* 현재 eye+lens 설정 기준 affine 왜곡 결과를 반환합니다.
|
|
9283
|
-
* traced ray/affine 결과는 기존 계산값을 우선 재사용합니다.
|
|
9284
|
-
*/
|
|
9285
9272
|
getAffineAnalysis() {
|
|
9273
|
+
/*
|
|
9286
9274
|
if (!this.tracedRays.length) {
|
|
9287
|
-
|
|
9275
|
+
this.simulate();
|
|
9288
9276
|
}
|
|
9289
9277
|
if (!this.lastAffineAnalysis) {
|
|
9290
|
-
|
|
9278
|
+
this.lastAffineAnalysis = this.estimateAffineDistortion(this.createAffinePairs(this.tracedRays));
|
|
9291
9279
|
}
|
|
9292
9280
|
return this.lastAffineAnalysis;
|
|
9281
|
+
*/
|
|
9282
|
+
// Affine analysis is intentionally disabled for now.
|
|
9283
|
+
return null;
|
|
9293
9284
|
}
|
|
9294
9285
|
surfaceOrderZ(surface) {
|
|
9295
9286
|
const z = Number(this.readSurfacePosition(surface)?.z);
|
|
@@ -9541,6 +9532,13 @@
|
|
|
9541
9532
|
}
|
|
9542
9533
|
return 2 * Math.hypot(j0, j45);
|
|
9543
9534
|
}
|
|
9535
|
+
// Kept for later review/release.
|
|
9536
|
+
estimateAffineDistortion(pairs) {
|
|
9537
|
+
const inputPairs = Array.isArray(pairs) ? pairs : [];
|
|
9538
|
+
this.lastAffineAnalysis = this.affine.estimate(inputPairs);
|
|
9539
|
+
return this.lastAffineAnalysis;
|
|
9540
|
+
}
|
|
9541
|
+
// Kept for later review/release.
|
|
9544
9542
|
createAffinePairs(rays) {
|
|
9545
9543
|
return (Array.isArray(rays) ? rays : [])
|
|
9546
9544
|
.map((ray) => {
|
|
@@ -112,7 +112,7 @@ export type AffineAnalysisResult = ReturnType<Affine["estimate"]>;
|
|
|
112
112
|
* legacy simulator.js를 TypeScript로 옮긴 핵심 시뮬레이터입니다.
|
|
113
113
|
* - 광원 광선을 생성하고
|
|
114
114
|
* - 표면들을 순서대로 통과시키며 굴절을 계산한 뒤
|
|
115
|
-
* -
|
|
115
|
+
* - Sturm 분석까지 제공합니다.
|
|
116
116
|
*/
|
|
117
117
|
export declare class SCAXEngineCore {
|
|
118
118
|
private static readonly EYE_ROTATION_PIVOT_FROM_CORNEA_MM;
|
|
@@ -289,15 +289,6 @@ export declare class SCAXEngineCore {
|
|
|
289
289
|
};
|
|
290
290
|
}[];
|
|
291
291
|
};
|
|
292
|
-
/**
|
|
293
|
-
* 3) Affine 왜곡 추정 전용 함수
|
|
294
|
-
* 광선 대응쌍(sx,sy)->(tx,ty)에 대해 최소자승 2D affine을 적합합니다.
|
|
295
|
-
*/
|
|
296
|
-
private estimateAffineDistortion;
|
|
297
|
-
/**
|
|
298
|
-
* 현재 eye+lens 설정 기준 affine 왜곡 결과를 반환합니다.
|
|
299
|
-
* traced ray/affine 결과는 기존 계산값을 우선 재사용합니다.
|
|
300
|
-
*/
|
|
301
292
|
getAffineAnalysis(): AffineAnalysisResult;
|
|
302
293
|
private surfaceOrderZ;
|
|
303
294
|
private readSurfacePosition;
|
|
@@ -327,6 +318,7 @@ export declare class SCAXEngineCore {
|
|
|
327
318
|
private applyLightSourceTransformToRay;
|
|
328
319
|
private calculateLightDeviation;
|
|
329
320
|
private effectiveCylinderFromOpticSurfaces;
|
|
321
|
+
private estimateAffineDistortion;
|
|
330
322
|
private createAffinePairs;
|
|
331
323
|
}
|
|
332
324
|
/**
|
package/package.json
CHANGED