@bluemoonfoundry/daz-ts 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +377 -2
- package/dist/animation.d.ts +129 -0
- package/dist/animation.js +276 -0
- package/dist/batch.d.ts +118 -0
- package/dist/batch.js +186 -0
- package/dist/bone.d.ts +50 -0
- package/dist/bone.js +66 -0
- package/dist/camera.d.ts +61 -0
- package/dist/camera.js +120 -0
- package/dist/cinematics.d.ts +188 -0
- package/dist/cinematics.js +165 -0
- package/dist/client.d.ts +399 -0
- package/dist/client.js +769 -0
- package/dist/dforce.d.ts +15 -0
- package/dist/dforce.js +36 -0
- package/dist/element.d.ts +51 -0
- package/dist/element.js +141 -0
- package/dist/exceptions.d.ts +124 -0
- package/dist/exceptions.js +173 -0
- package/dist/geometry.d.ts +81 -0
- package/dist/geometry.js +433 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +36 -0
- package/dist/light.d.ts +24 -0
- package/dist/light.js +40 -0
- package/dist/lighting.d.ts +120 -0
- package/dist/lighting.js +107 -0
- package/dist/material.d.ts +27 -0
- package/dist/material.js +63 -0
- package/dist/materials.d.ts +107 -0
- package/dist/materials.js +165 -0
- package/dist/math3.d.ts +204 -0
- package/dist/math3.js +502 -0
- package/dist/modifier.d.ts +14 -0
- package/dist/modifier.js +24 -0
- package/dist/morph.d.ts +11 -0
- package/dist/morph.js +24 -0
- package/dist/node.d.ts +196 -0
- package/dist/node.js +447 -0
- package/dist/polling.d.ts +24 -0
- package/dist/polling.js +50 -0
- package/dist/pose.d.ts +82 -0
- package/dist/pose.js +295 -0
- package/dist/poses.d.ts +54 -0
- package/dist/poses.js +40 -0
- package/dist/property.d.ts +64 -0
- package/dist/property.js +125 -0
- package/dist/render.d.ts +242 -0
- package/dist/render.js +811 -0
- package/dist/renderApi.d.ts +124 -0
- package/dist/renderApi.js +235 -0
- package/dist/result.d.ts +15 -0
- package/dist/result.js +1 -0
- package/dist/scene.d.ts +154 -0
- package/dist/scene.js +584 -0
- package/dist/sceneEvents.d.ts +63 -0
- package/dist/sceneEvents.js +102 -0
- package/dist/sceneState.d.ts +167 -0
- package/dist/sceneState.js +430 -0
- package/dist/scriptBuilder.d.ts +41 -0
- package/dist/scriptBuilder.js +72 -0
- package/dist/shotGeometry.d.ts +49 -0
- package/dist/shotGeometry.js +76 -0
- package/dist/skeleton.d.ts +120 -0
- package/dist/skeleton.js +561 -0
- package/dist/timeline.d.ts +24 -0
- package/dist/timeline.js +39 -0
- package/dist/undo.d.ts +24 -0
- package/dist/undo.js +45 -0
- package/dist/version.d.ts +31 -0
- package/dist/version.js +36 -0
- package/dist/viewport.d.ts +58 -0
- package/dist/viewport.js +239 -0
- package/package.json +52 -4
package/dist/dforce.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DazModifier } from "./modifier.js";
|
|
2
|
+
/**
|
|
3
|
+
* Proxy for a `DzDForceModifier` (cloth/hair dForce simulation modifier).
|
|
4
|
+
* Tunables not covered here (e.g. "Dynamics Strength") are reachable via
|
|
5
|
+
* the inherited `DazElement.getProperty`/`.setProperty`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DazDForce extends DazModifier {
|
|
8
|
+
/** Whether the simulated result is frozen onto the mesh (read/write) — DAZ Studio's equivalent of "baking" a dForce result. */
|
|
9
|
+
freezeSimulation(): Promise<boolean | null>;
|
|
10
|
+
setFreezeSimulation(value: boolean): Promise<void>;
|
|
11
|
+
/** Bake the current simulated result onto the mesh. */
|
|
12
|
+
freeze(): Promise<void>;
|
|
13
|
+
/** Release a frozen simulation so it resumes following the dForce solve. */
|
|
14
|
+
unfreeze(): Promise<void>;
|
|
15
|
+
}
|
package/dist/dforce.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DazModifier } from "./modifier.js";
|
|
2
|
+
import { ScriptBuilder } from "./scriptBuilder.js";
|
|
3
|
+
/**
|
|
4
|
+
* Proxy for a `DzDForceModifier` (cloth/hair dForce simulation modifier).
|
|
5
|
+
* Tunables not covered here (e.g. "Dynamics Strength") are reachable via
|
|
6
|
+
* the inherited `DazElement.getProperty`/`.setProperty`.
|
|
7
|
+
*/
|
|
8
|
+
export class DazDForce extends DazModifier {
|
|
9
|
+
/** Whether the simulated result is frozen onto the mesh (read/write) — DAZ Studio's equivalent of "baking" a dForce result. */
|
|
10
|
+
async freezeSimulation() {
|
|
11
|
+
const script = ScriptBuilder.iife(`
|
|
12
|
+
var m = ${this.locator};
|
|
13
|
+
if (!m) return null;
|
|
14
|
+
var p = m.findPropertyByLabel("Freeze Simulation");
|
|
15
|
+
return p ? p.getValue() : null;
|
|
16
|
+
`);
|
|
17
|
+
return (await this.client.execute(script)).value;
|
|
18
|
+
}
|
|
19
|
+
async setFreezeSimulation(value) {
|
|
20
|
+
const script = ScriptBuilder.iife(`
|
|
21
|
+
var m = ${this.locator};
|
|
22
|
+
if (!m) return;
|
|
23
|
+
var p = m.findPropertyByLabel("Freeze Simulation");
|
|
24
|
+
if (p) p.setValue(${ScriptBuilder.serializeArg(value)});
|
|
25
|
+
`);
|
|
26
|
+
await this.client.execute(script);
|
|
27
|
+
}
|
|
28
|
+
/** Bake the current simulated result onto the mesh. */
|
|
29
|
+
async freeze() {
|
|
30
|
+
await this.setFreezeSimulation(true);
|
|
31
|
+
}
|
|
32
|
+
/** Release a frozen simulation so it resumes following the dForce solve. */
|
|
33
|
+
async unfreeze() {
|
|
34
|
+
await this.setFreezeSimulation(false);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { DazClient } from "./client.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generic proxy for any `DzElement` subclass. Base class for every typed
|
|
4
|
+
* proxy in this SDK (`DazNode`, `DazMaterial`, etc.).
|
|
5
|
+
*
|
|
6
|
+
* `locator` is a DazScript expression that evaluates to the underlying
|
|
7
|
+
* `DzElement` instance inside DAZ Studio; every method wraps a small IIFE
|
|
8
|
+
* around it via {@link ScriptBuilder.iife}.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DazElement {
|
|
11
|
+
protected readonly client: DazClient;
|
|
12
|
+
protected readonly locator: string;
|
|
13
|
+
private readonly cache;
|
|
14
|
+
constructor(client: DazClient, locator: string);
|
|
15
|
+
/**
|
|
16
|
+
* The underlying {@link DazClient}, for domain-helper modules (`pose.ts`,
|
|
17
|
+
* `sceneState.ts`, `animation.ts`, `materials.ts`, ...) that need to issue
|
|
18
|
+
* their own custom scripts against this element. Mirrors dazpy's
|
|
19
|
+
* soft-private `_client` attribute, which sibling modules like
|
|
20
|
+
* `materials.py`/`lighting.py` access directly.
|
|
21
|
+
*/
|
|
22
|
+
getClient(): DazClient;
|
|
23
|
+
/** The DazScript locator expression for this element. See {@link getClient}. */
|
|
24
|
+
getLocator(): string;
|
|
25
|
+
/** Return the current value of a property looked up by its display label, or `null` if not found. */
|
|
26
|
+
getProperty(label: string): Promise<unknown>;
|
|
27
|
+
/** Set a property value by display label. `value` must be JSON-serializable. */
|
|
28
|
+
setProperty(label: string, value: unknown): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Set multiple property values by display label in one call.
|
|
31
|
+
* @returns `{label: true}` for labels that resolved to a real property and were written, `{label: false}` otherwise.
|
|
32
|
+
*/
|
|
33
|
+
setProperties(values: Record<string, unknown>): Promise<Record<string, boolean>>;
|
|
34
|
+
/** Return metadata (`label`/`name`/`type`) for every property on this element. */
|
|
35
|
+
listProperties(): Promise<Array<{
|
|
36
|
+
label: string;
|
|
37
|
+
name: string;
|
|
38
|
+
type: string;
|
|
39
|
+
}>>;
|
|
40
|
+
/** Return every numeric property on this element as `{label: value}` in a single HTTP round-trip. */
|
|
41
|
+
numericProperties(): Promise<Record<string, unknown>>;
|
|
42
|
+
/** The DazScript class name of this element (e.g. `"DzFigure"`), or `null` if the locator resolves to nothing. */
|
|
43
|
+
className(): Promise<string | null>;
|
|
44
|
+
/**
|
|
45
|
+
* Read and cache a set of property values in a single call.
|
|
46
|
+
* Missing owner or missing property both resolve to `null` for the affected label(s).
|
|
47
|
+
*/
|
|
48
|
+
snapshot(fields: string[]): Promise<Record<string, unknown>>;
|
|
49
|
+
/** Clear the local property cache populated by {@link snapshot} so the next read fetches live data. */
|
|
50
|
+
refresh(): void;
|
|
51
|
+
}
|
package/dist/element.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { ScriptBuilder } from "./scriptBuilder.js";
|
|
2
|
+
/**
|
|
3
|
+
* Generic proxy for any `DzElement` subclass. Base class for every typed
|
|
4
|
+
* proxy in this SDK (`DazNode`, `DazMaterial`, etc.).
|
|
5
|
+
*
|
|
6
|
+
* `locator` is a DazScript expression that evaluates to the underlying
|
|
7
|
+
* `DzElement` instance inside DAZ Studio; every method wraps a small IIFE
|
|
8
|
+
* around it via {@link ScriptBuilder.iife}.
|
|
9
|
+
*/
|
|
10
|
+
export class DazElement {
|
|
11
|
+
client;
|
|
12
|
+
locator;
|
|
13
|
+
cache = new Map();
|
|
14
|
+
constructor(client, locator) {
|
|
15
|
+
this.client = client;
|
|
16
|
+
this.locator = locator;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The underlying {@link DazClient}, for domain-helper modules (`pose.ts`,
|
|
20
|
+
* `sceneState.ts`, `animation.ts`, `materials.ts`, ...) that need to issue
|
|
21
|
+
* their own custom scripts against this element. Mirrors dazpy's
|
|
22
|
+
* soft-private `_client` attribute, which sibling modules like
|
|
23
|
+
* `materials.py`/`lighting.py` access directly.
|
|
24
|
+
*/
|
|
25
|
+
getClient() {
|
|
26
|
+
return this.client;
|
|
27
|
+
}
|
|
28
|
+
/** The DazScript locator expression for this element. See {@link getClient}. */
|
|
29
|
+
getLocator() {
|
|
30
|
+
return this.locator;
|
|
31
|
+
}
|
|
32
|
+
/** Return the current value of a property looked up by its display label, or `null` if not found. */
|
|
33
|
+
async getProperty(label) {
|
|
34
|
+
const script = ScriptBuilder.iife(` var obj = ${this.locator};
|
|
35
|
+
if (!obj) return null;
|
|
36
|
+
var prop = obj.findPropertyByLabel(${ScriptBuilder.escapeString(label)});
|
|
37
|
+
if (!prop) return null;
|
|
38
|
+
return prop.getValue();
|
|
39
|
+
`);
|
|
40
|
+
return (await this.client.execute(script)).value;
|
|
41
|
+
}
|
|
42
|
+
/** Set a property value by display label. `value` must be JSON-serializable. */
|
|
43
|
+
async setProperty(label, value) {
|
|
44
|
+
const serialized = ScriptBuilder.serializeArg(value);
|
|
45
|
+
const script = ScriptBuilder.iife(` var obj = ${this.locator};
|
|
46
|
+
if (!obj) return {"error": "not_found"};
|
|
47
|
+
var prop = obj.findPropertyByLabel(${ScriptBuilder.escapeString(label)});
|
|
48
|
+
if (!prop) return {"error": "property_not_found"};
|
|
49
|
+
prop.setValue(${serialized});
|
|
50
|
+
return {"success": true};
|
|
51
|
+
`);
|
|
52
|
+
await this.client.execute(script);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Set multiple property values by display label in one call.
|
|
56
|
+
* @returns `{label: true}` for labels that resolved to a real property and were written, `{label: false}` otherwise.
|
|
57
|
+
*/
|
|
58
|
+
async setProperties(values) {
|
|
59
|
+
const dataJson = JSON.stringify(values);
|
|
60
|
+
const script = ScriptBuilder.iife(` var obj = ${this.locator};
|
|
61
|
+
if (!obj) return null;
|
|
62
|
+
var _data = ${dataJson};
|
|
63
|
+
var _result = {};
|
|
64
|
+
for (var _label in _data) {
|
|
65
|
+
if (!_data.hasOwnProperty(_label)) continue;
|
|
66
|
+
var prop = obj.findPropertyByLabel(_label);
|
|
67
|
+
if (prop) {
|
|
68
|
+
prop.setValue(_data[_label]);
|
|
69
|
+
_result[_label] = true;
|
|
70
|
+
} else {
|
|
71
|
+
_result[_label] = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return _result;
|
|
75
|
+
`);
|
|
76
|
+
return (await this.client.execute(script)).value ?? {};
|
|
77
|
+
}
|
|
78
|
+
/** Return metadata (`label`/`name`/`type`) for every property on this element. */
|
|
79
|
+
async listProperties() {
|
|
80
|
+
const script = ScriptBuilder.iife(` var obj = ${this.locator};
|
|
81
|
+
if (!obj) return null;
|
|
82
|
+
var result = [];
|
|
83
|
+
for (var i = 0; i < obj.getNumProperties(); i++) {
|
|
84
|
+
var p = obj.getProperty(i);
|
|
85
|
+
result.push({"label": p.getLabel(), "name": p.getName(), "type": p.className()});
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
`);
|
|
89
|
+
return (await this.client.execute(script)).value ?? [];
|
|
90
|
+
}
|
|
91
|
+
/** Return every numeric property on this element as `{label: value}` in a single HTTP round-trip. */
|
|
92
|
+
async numericProperties() {
|
|
93
|
+
const script = ScriptBuilder.iife(` var obj = ${this.locator};
|
|
94
|
+
if (!obj) return null;
|
|
95
|
+
var result = {};
|
|
96
|
+
for (var i = 0; i < obj.getNumProperties(); i++) {
|
|
97
|
+
var p = obj.getProperty(i);
|
|
98
|
+
if (p.inherits("DzNumericProperty")) {
|
|
99
|
+
result[p.getLabel()] = p.getValue();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return result;
|
|
103
|
+
`);
|
|
104
|
+
return (await this.client.execute(script)).value ?? {};
|
|
105
|
+
}
|
|
106
|
+
/** The DazScript class name of this element (e.g. `"DzFigure"`), or `null` if the locator resolves to nothing. */
|
|
107
|
+
async className() {
|
|
108
|
+
const script = ScriptBuilder.iife(`var obj = ${this.locator}; return obj ? obj.className() : null;`);
|
|
109
|
+
return (await this.client.execute(script)).value;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Read and cache a set of property values in a single call.
|
|
113
|
+
* Missing owner or missing property both resolve to `null` for the affected label(s).
|
|
114
|
+
*/
|
|
115
|
+
async snapshot(fields) {
|
|
116
|
+
const fieldsJson = JSON.stringify(fields);
|
|
117
|
+
const script = ScriptBuilder.iife(` var obj = ${this.locator};
|
|
118
|
+
if (!obj) return null;
|
|
119
|
+
var _fields = ${fieldsJson};
|
|
120
|
+
var _result = {};
|
|
121
|
+
for (var i = 0; i < _fields.length; i++) {
|
|
122
|
+
var prop = obj.findPropertyByLabel(_fields[i]);
|
|
123
|
+
_result[_fields[i]] = prop ? prop.getValue() : null;
|
|
124
|
+
}
|
|
125
|
+
return _result;
|
|
126
|
+
`);
|
|
127
|
+
const values = (await this.client.execute(script)).value ?? {};
|
|
128
|
+
for (const field of fields) {
|
|
129
|
+
this.cache.set(field, values[field] ?? null);
|
|
130
|
+
}
|
|
131
|
+
const out = {};
|
|
132
|
+
for (const field of fields) {
|
|
133
|
+
out[field] = this.cache.get(field);
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
/** Clear the local property cache populated by {@link snapshot} so the next read fetches live data. */
|
|
138
|
+
refresh() {
|
|
139
|
+
this.cache.clear();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/** Base class for all daz-ts exceptions. */
|
|
2
|
+
export declare class DazError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/** Raised when the SDK cannot reach the DAZ Studio Script Server. */
|
|
6
|
+
export declare class ConnectionError extends DazError {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Raised on HTTP 401 or 403 (bad or missing API token, or IP blocked).
|
|
10
|
+
*
|
|
11
|
+
* Carries the server's `ErrorResponse` fields when the body had them
|
|
12
|
+
* (e.g. `errorCode` `"AUTH_INVALID_TOKEN"` or `"IP_NOT_WHITELISTED"`).
|
|
13
|
+
*/
|
|
14
|
+
export declare class AuthenticationError extends DazError {
|
|
15
|
+
/** HTTP status code (401 or 403). */
|
|
16
|
+
readonly statusCode: number;
|
|
17
|
+
/** The server's `error_code`, or `""` when the body had none. */
|
|
18
|
+
readonly errorCode: string;
|
|
19
|
+
/** Optional structured detail from the server response. */
|
|
20
|
+
readonly detail: string;
|
|
21
|
+
/** True when the server says an identical retry may succeed. */
|
|
22
|
+
readonly retryable: boolean;
|
|
23
|
+
constructor(message: string, statusCode?: number, errorCode?: string, detail?: string, retryable?: boolean);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Base class for transient "DAZ Studio is busy, please retry" conditions.
|
|
27
|
+
*/
|
|
28
|
+
export declare class DazBusyError extends DazError {
|
|
29
|
+
/** Human-readable explanation of why the server is busy. */
|
|
30
|
+
readonly reason: string;
|
|
31
|
+
/** Server-suggested seconds to wait before retrying. */
|
|
32
|
+
readonly retryAfter: number;
|
|
33
|
+
constructor(message: string, reason?: string, retryAfter?: number);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Raised on HTTP 503 STUDIO_BUSY: DAZ Studio's main thread is occupied
|
|
37
|
+
* with a scene load, save, clear, or render and cannot service the request.
|
|
38
|
+
*/
|
|
39
|
+
export declare class StudioBusyError extends DazBusyError {
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Raised on HTTP 429 CONCURRENT_LIMIT_EXCEEDED: too many requests are
|
|
43
|
+
* already in flight against the server.
|
|
44
|
+
*/
|
|
45
|
+
export declare class ConcurrencyLimitError extends DazBusyError {
|
|
46
|
+
}
|
|
47
|
+
/** Base class for errors that originate inside a DazScript execution. */
|
|
48
|
+
export declare class ScriptError extends DazError {
|
|
49
|
+
/** The DazScript source that was submitted (may be empty for file-based executions). */
|
|
50
|
+
readonly script: string;
|
|
51
|
+
/** The server-assigned request ID, useful for log correlation. */
|
|
52
|
+
readonly requestId: string;
|
|
53
|
+
/** Lines written to the DAZ Studio message log before the error. */
|
|
54
|
+
readonly output: string[];
|
|
55
|
+
constructor(message: string, script?: string, requestId?: string, output?: string[]);
|
|
56
|
+
/** A formatted string with line-numbered source and error details. */
|
|
57
|
+
get diagnostic(): string;
|
|
58
|
+
}
|
|
59
|
+
/** Raised when the DazScript engine reports a parse / syntax error. */
|
|
60
|
+
export declare class ScriptSyntaxError extends ScriptError {
|
|
61
|
+
}
|
|
62
|
+
/** Raised when a DazScript execution fails at runtime (TypeError, ReferenceError, etc.). */
|
|
63
|
+
export declare class ScriptRuntimeError extends ScriptError {
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Raised when an HTTP request or async poll exceeds its timeout.
|
|
67
|
+
*
|
|
68
|
+
* Named `DazTimeoutError` (not `TimeoutError`) to avoid shadowing the
|
|
69
|
+
* platform's built-in exception name.
|
|
70
|
+
*/
|
|
71
|
+
export declare class DazTimeoutError extends DazError {
|
|
72
|
+
}
|
|
73
|
+
/** Raised when a requested scene node, bone, or skeleton cannot be found. */
|
|
74
|
+
export declare class NodeNotFoundError extends DazError {
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Raised when an async request fails, is cancelled, or times out while polling.
|
|
78
|
+
*/
|
|
79
|
+
export declare class AsyncExecutionError extends DazError {
|
|
80
|
+
/** The server-assigned request ID of the failed async job. */
|
|
81
|
+
readonly requestId: string;
|
|
82
|
+
constructor(message: string, requestId?: string);
|
|
83
|
+
}
|
|
84
|
+
/** Raised when a render job fails on the DAZ Studio side. */
|
|
85
|
+
export declare class RenderError extends DazError {
|
|
86
|
+
/** The server-assigned render request ID. */
|
|
87
|
+
readonly requestId: string;
|
|
88
|
+
constructor(message: string, requestId?: string);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Raised by {@link Batch.execute} (or `addOperation`, for the operation-count
|
|
92
|
+
* limit) when a batch would exceed its configured operation-count or
|
|
93
|
+
* generated-script-length limit.
|
|
94
|
+
*
|
|
95
|
+
* Raised client-side before any HTTP call, so an oversized batch never
|
|
96
|
+
* reaches Studio's main thread.
|
|
97
|
+
*/
|
|
98
|
+
export declare class BatchLimitExceededError extends DazError {
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Raised when an Iray material/surface-property operation fails.
|
|
102
|
+
*
|
|
103
|
+
* Covers a missing material, a channel label that doesn't resolve to a
|
|
104
|
+
* property on the live material, or a failed `setValue()`/`setMap()`.
|
|
105
|
+
*/
|
|
106
|
+
export declare class MaterialError extends DazError {
|
|
107
|
+
/** Request ID of the failing server call, or `""` when not known. */
|
|
108
|
+
readonly requestId: string;
|
|
109
|
+
constructor(message: string, requestId?: string);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Raised by the artifact download helpers when the server rejects the
|
|
113
|
+
* request: `ARTIFACT_NOT_FOUND` (404, the job declared no such artifact),
|
|
114
|
+
* `ARTIFACT_UNAVAILABLE` (410, the declared file is gone), `REQUEST_NOT_FOUND`
|
|
115
|
+
* (404, unknown or expired job), `INVALID_FIELD` (400) or HTTP 416 for a byte
|
|
116
|
+
* range outside the file.
|
|
117
|
+
*/
|
|
118
|
+
export declare class ArtifactError extends DazError {
|
|
119
|
+
/** HTTP status code of the rejection. */
|
|
120
|
+
readonly statusCode: number;
|
|
121
|
+
/** The server's `error_code`, or `""` when the body had none (e.g. 416). */
|
|
122
|
+
readonly errorCode: string;
|
|
123
|
+
constructor(message: string, statusCode: number, errorCode?: string);
|
|
124
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/** Base class for all daz-ts exceptions. */
|
|
2
|
+
export class DazError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = new.target.name;
|
|
6
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** Raised when the SDK cannot reach the DAZ Studio Script Server. */
|
|
10
|
+
export class ConnectionError extends DazError {
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Raised on HTTP 401 or 403 (bad or missing API token, or IP blocked).
|
|
14
|
+
*
|
|
15
|
+
* Carries the server's `ErrorResponse` fields when the body had them
|
|
16
|
+
* (e.g. `errorCode` `"AUTH_INVALID_TOKEN"` or `"IP_NOT_WHITELISTED"`).
|
|
17
|
+
*/
|
|
18
|
+
export class AuthenticationError extends DazError {
|
|
19
|
+
/** HTTP status code (401 or 403). */
|
|
20
|
+
statusCode;
|
|
21
|
+
/** The server's `error_code`, or `""` when the body had none. */
|
|
22
|
+
errorCode;
|
|
23
|
+
/** Optional structured detail from the server response. */
|
|
24
|
+
detail;
|
|
25
|
+
/** True when the server says an identical retry may succeed. */
|
|
26
|
+
retryable;
|
|
27
|
+
constructor(message, statusCode = 401, errorCode = "", detail = "", retryable = false) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.statusCode = statusCode;
|
|
30
|
+
this.errorCode = errorCode;
|
|
31
|
+
this.detail = detail;
|
|
32
|
+
this.retryable = retryable;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Base class for transient "DAZ Studio is busy, please retry" conditions.
|
|
37
|
+
*/
|
|
38
|
+
export class DazBusyError extends DazError {
|
|
39
|
+
/** Human-readable explanation of why the server is busy. */
|
|
40
|
+
reason;
|
|
41
|
+
/** Server-suggested seconds to wait before retrying. */
|
|
42
|
+
retryAfter;
|
|
43
|
+
constructor(message, reason = "", retryAfter = 2.0) {
|
|
44
|
+
super(message);
|
|
45
|
+
this.reason = reason;
|
|
46
|
+
this.retryAfter = retryAfter;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Raised on HTTP 503 STUDIO_BUSY: DAZ Studio's main thread is occupied
|
|
51
|
+
* with a scene load, save, clear, or render and cannot service the request.
|
|
52
|
+
*/
|
|
53
|
+
export class StudioBusyError extends DazBusyError {
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Raised on HTTP 429 CONCURRENT_LIMIT_EXCEEDED: too many requests are
|
|
57
|
+
* already in flight against the server.
|
|
58
|
+
*/
|
|
59
|
+
export class ConcurrencyLimitError extends DazBusyError {
|
|
60
|
+
}
|
|
61
|
+
/** Base class for errors that originate inside a DazScript execution. */
|
|
62
|
+
export class ScriptError extends DazError {
|
|
63
|
+
/** The DazScript source that was submitted (may be empty for file-based executions). */
|
|
64
|
+
script;
|
|
65
|
+
/** The server-assigned request ID, useful for log correlation. */
|
|
66
|
+
requestId;
|
|
67
|
+
/** Lines written to the DAZ Studio message log before the error. */
|
|
68
|
+
output;
|
|
69
|
+
constructor(message, script = "", requestId = "", output = []) {
|
|
70
|
+
super(message);
|
|
71
|
+
this.script = script;
|
|
72
|
+
this.requestId = requestId;
|
|
73
|
+
this.output = output;
|
|
74
|
+
}
|
|
75
|
+
/** A formatted string with line-numbered source and error details. */
|
|
76
|
+
get diagnostic() {
|
|
77
|
+
const lines = [];
|
|
78
|
+
if (this.script) {
|
|
79
|
+
const numbered = this.script
|
|
80
|
+
.split("\n")
|
|
81
|
+
.map((line, i) => `${String(i + 1).padStart(4, " ")}: ${line}`)
|
|
82
|
+
.join("\n");
|
|
83
|
+
lines.push(numbered);
|
|
84
|
+
}
|
|
85
|
+
lines.push(this.message);
|
|
86
|
+
if (this.output.length > 0) {
|
|
87
|
+
lines.push("\nCaptured output:\n" + this.output.join("\n"));
|
|
88
|
+
}
|
|
89
|
+
if (this.requestId) {
|
|
90
|
+
lines.push(`request_id: ${this.requestId}`);
|
|
91
|
+
}
|
|
92
|
+
return lines.join("\n");
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** Raised when the DazScript engine reports a parse / syntax error. */
|
|
96
|
+
export class ScriptSyntaxError extends ScriptError {
|
|
97
|
+
}
|
|
98
|
+
/** Raised when a DazScript execution fails at runtime (TypeError, ReferenceError, etc.). */
|
|
99
|
+
export class ScriptRuntimeError extends ScriptError {
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Raised when an HTTP request or async poll exceeds its timeout.
|
|
103
|
+
*
|
|
104
|
+
* Named `DazTimeoutError` (not `TimeoutError`) to avoid shadowing the
|
|
105
|
+
* platform's built-in exception name.
|
|
106
|
+
*/
|
|
107
|
+
export class DazTimeoutError extends DazError {
|
|
108
|
+
}
|
|
109
|
+
/** Raised when a requested scene node, bone, or skeleton cannot be found. */
|
|
110
|
+
export class NodeNotFoundError extends DazError {
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Raised when an async request fails, is cancelled, or times out while polling.
|
|
114
|
+
*/
|
|
115
|
+
export class AsyncExecutionError extends DazError {
|
|
116
|
+
/** The server-assigned request ID of the failed async job. */
|
|
117
|
+
requestId;
|
|
118
|
+
constructor(message, requestId = "") {
|
|
119
|
+
super(message);
|
|
120
|
+
this.requestId = requestId;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** Raised when a render job fails on the DAZ Studio side. */
|
|
124
|
+
export class RenderError extends DazError {
|
|
125
|
+
/** The server-assigned render request ID. */
|
|
126
|
+
requestId;
|
|
127
|
+
constructor(message, requestId = "") {
|
|
128
|
+
super(message);
|
|
129
|
+
this.requestId = requestId;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Raised by {@link Batch.execute} (or `addOperation`, for the operation-count
|
|
134
|
+
* limit) when a batch would exceed its configured operation-count or
|
|
135
|
+
* generated-script-length limit.
|
|
136
|
+
*
|
|
137
|
+
* Raised client-side before any HTTP call, so an oversized batch never
|
|
138
|
+
* reaches Studio's main thread.
|
|
139
|
+
*/
|
|
140
|
+
export class BatchLimitExceededError extends DazError {
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Raised when an Iray material/surface-property operation fails.
|
|
144
|
+
*
|
|
145
|
+
* Covers a missing material, a channel label that doesn't resolve to a
|
|
146
|
+
* property on the live material, or a failed `setValue()`/`setMap()`.
|
|
147
|
+
*/
|
|
148
|
+
export class MaterialError extends DazError {
|
|
149
|
+
/** Request ID of the failing server call, or `""` when not known. */
|
|
150
|
+
requestId;
|
|
151
|
+
constructor(message, requestId = "") {
|
|
152
|
+
super(message);
|
|
153
|
+
this.requestId = requestId;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Raised by the artifact download helpers when the server rejects the
|
|
158
|
+
* request: `ARTIFACT_NOT_FOUND` (404, the job declared no such artifact),
|
|
159
|
+
* `ARTIFACT_UNAVAILABLE` (410, the declared file is gone), `REQUEST_NOT_FOUND`
|
|
160
|
+
* (404, unknown or expired job), `INVALID_FIELD` (400) or HTTP 416 for a byte
|
|
161
|
+
* range outside the file.
|
|
162
|
+
*/
|
|
163
|
+
export class ArtifactError extends DazError {
|
|
164
|
+
/** HTTP status code of the rejection. */
|
|
165
|
+
statusCode;
|
|
166
|
+
/** The server's `error_code`, or `""` when the body had none (e.g. 416). */
|
|
167
|
+
errorCode;
|
|
168
|
+
constructor(message, statusCode, errorCode = "") {
|
|
169
|
+
super(message);
|
|
170
|
+
this.statusCode = statusCode;
|
|
171
|
+
this.errorCode = errorCode;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { DazClient } from "./client.js";
|
|
2
|
+
import { DazElement } from "./element.js";
|
|
3
|
+
import { BoundingBox, Vec3 } from "./math3.js";
|
|
4
|
+
import type { NodeIdentifier } from "./node.js";
|
|
5
|
+
/** Chunked access to vertices, faces, normals, UV sets, and face/material groups for a node's current shape's geometry. */
|
|
6
|
+
export declare class DazGeometry extends DazElement {
|
|
7
|
+
private readonly nodeExpr;
|
|
8
|
+
constructor(client: DazClient, identifier: NodeIdentifier);
|
|
9
|
+
/** Total number of vertices in the mesh (read-only). */
|
|
10
|
+
vertexCount(): Promise<number | null>;
|
|
11
|
+
/** Total number of faces (triangles + quads, read-only). */
|
|
12
|
+
facetCount(): Promise<number | null>;
|
|
13
|
+
/** One chunk of vertex positions. `start`/`count` default to `0`/`5000`. */
|
|
14
|
+
vertexPositions(start?: number, count?: number): Promise<{
|
|
15
|
+
total: number;
|
|
16
|
+
start: number;
|
|
17
|
+
count: number;
|
|
18
|
+
vertices: number[][];
|
|
19
|
+
}>;
|
|
20
|
+
/** Every vertex position, auto-paginating by `chunkSize` (default `5000`). */
|
|
21
|
+
vertexPositionsAll(chunkSize?: number): Promise<number[][]>;
|
|
22
|
+
/** One chunk of face vertex indices; each entry is `[v0,v1,v2]` (tri) or `[v0,v1,v2,v3]` (quad). `start`/`count` default `0`/`1000`. */
|
|
23
|
+
faceVertexIndices(start?: number, count?: number): Promise<{
|
|
24
|
+
total: number;
|
|
25
|
+
start: number;
|
|
26
|
+
facets: number[][];
|
|
27
|
+
}>;
|
|
28
|
+
/** Every face's vertex indices, auto-paginating by `chunkSize` (default `1000`). */
|
|
29
|
+
faceVertexIndicesAll(chunkSize?: number): Promise<number[][]>;
|
|
30
|
+
/** One chunk of face normals. `start`/`count` default `0`/`5000`. */
|
|
31
|
+
normals(start?: number, count?: number): Promise<{
|
|
32
|
+
total: number;
|
|
33
|
+
start: number;
|
|
34
|
+
normals: number[][];
|
|
35
|
+
}>;
|
|
36
|
+
/** Every face normal, auto-paginating by `chunkSize` (default `5000`). */
|
|
37
|
+
normalsAll(chunkSize?: number): Promise<number[][]>;
|
|
38
|
+
/** Number of UV sets on this mesh (read-only). */
|
|
39
|
+
uvSetCount(): Promise<number | null>;
|
|
40
|
+
/** One chunk of UV coordinates for `uvSet` (default `0`, the primary set uses `g.getUVs()` rather than `g.getUVSet(0)`). */
|
|
41
|
+
uvPositions(uvSet?: number, start?: number, count?: number): Promise<{
|
|
42
|
+
total: number;
|
|
43
|
+
start: number;
|
|
44
|
+
uvs: number[][];
|
|
45
|
+
}>;
|
|
46
|
+
/** Every UV coordinate for `uvSet`, auto-paginating by `chunkSize` (default `5000`). */
|
|
47
|
+
uvPositionsAll(uvSet?: number, chunkSize?: number): Promise<number[][]>;
|
|
48
|
+
faceGroupNames(): Promise<Array<string | null>>;
|
|
49
|
+
materialGroupNames(): Promise<Array<string | null>>;
|
|
50
|
+
/** Face indices belonging to the named face group, or `[]` if it doesn't exist. */
|
|
51
|
+
faceGroupFaces(name: string): Promise<number[]>;
|
|
52
|
+
/** Face indices belonging to the named material group, or `[]` if it doesn't exist. */
|
|
53
|
+
materialGroupFaces(name: string): Promise<number[]>;
|
|
54
|
+
/** Current subdivision level (`0` = base mesh, read-only). */
|
|
55
|
+
subdivisionLevel(): Promise<number | null>;
|
|
56
|
+
trisCount(): Promise<number | null>;
|
|
57
|
+
quadsCount(): Promise<number | null>;
|
|
58
|
+
/** All mesh metadata (vertex/facet/tri/quad counts, subdivision level, UV set count, group names) in a single HTTP call, instead of 7+ separate reads. */
|
|
59
|
+
meshInfo(): Promise<Record<string, unknown> | null>;
|
|
60
|
+
/** Axis-aligned bounding box of the base mesh, computed server-side in one HTTP call. `null` if unavailable or empty. */
|
|
61
|
+
boundingBox(): Promise<BoundingBox | null>;
|
|
62
|
+
/** AABB of the world-space posed-and-morphed mesh (after forcing a cache update), in one HTTP call. */
|
|
63
|
+
boundingBoxPosed(): Promise<BoundingBox | null>;
|
|
64
|
+
/** One chunk of fully-deformed world-space vertex positions (post morph-and-skinning), via `DzObject.getCachedGeom()`. */
|
|
65
|
+
vertexPositionsPosed(start?: number, count?: number): Promise<{
|
|
66
|
+
total: number;
|
|
67
|
+
start: number;
|
|
68
|
+
count: number;
|
|
69
|
+
vertices: number[][];
|
|
70
|
+
}>;
|
|
71
|
+
/** Every world-space posed+morphed vertex position, auto-paginating by `chunkSize` (default `5000`). */
|
|
72
|
+
vertexPositionsPosedAll(chunkSize?: number): Promise<number[][]>;
|
|
73
|
+
/**
|
|
74
|
+
* Convert face index arrays (tris or quads) to all-triangles. Quads split
|
|
75
|
+
* along the 0->2 diagonal (`[v0,v1,v2,v3]` -> `[v0,v1,v2]` + `[v0,v2,v3]`).
|
|
76
|
+
* Faces with any other vertex count are silently skipped. Pure function — no HTTP round-trip.
|
|
77
|
+
*/
|
|
78
|
+
static triangulate(faces: number[][]): number[][];
|
|
79
|
+
/** Wrap `[[x,y,z], ...]` vertex data as {@link Vec3} instances. Pure function — no HTTP round-trip. */
|
|
80
|
+
static asVec3(vertices: number[][]): Vec3[];
|
|
81
|
+
}
|