@kibee/renderer-three 0.1.0 → 0.2.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/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +65 -0
- package/dist/index.mjs +65 -0
- package/package.json +10 -3
package/dist/index.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
|
3
3
|
|
|
4
4
|
type BeeVisualState = "idle" | "guiding" | "thinking" | "celebrating";
|
|
5
5
|
type BeeAssetVariant = "hero" | "runtime";
|
|
6
|
+
type BeeAvatarPreset = "bee" | "orb" | "ring";
|
|
6
7
|
type BeeQualityTier = "auto" | "high" | "balanced" | "low";
|
|
7
8
|
type BeeMotionMode = "auto" | "full" | "reduced";
|
|
8
9
|
|
|
@@ -35,6 +36,7 @@ interface DockMotionOptions {
|
|
|
35
36
|
}
|
|
36
37
|
interface ThreeBeeRendererOptions {
|
|
37
38
|
assetUrl?: string;
|
|
39
|
+
avatarPreset?: BeeAvatarPreset;
|
|
38
40
|
assetVariant?: BeeAssetVariant;
|
|
39
41
|
qualityTier?: BeeQualityTier;
|
|
40
42
|
enableShadows?: boolean;
|
|
@@ -190,6 +192,8 @@ declare class ThreeBeeRenderer implements BeeRenderer {
|
|
|
190
192
|
private createRenderer;
|
|
191
193
|
private createLights;
|
|
192
194
|
private loadBeeModel;
|
|
195
|
+
private createPresetAvatar;
|
|
196
|
+
private clearVisualRig;
|
|
193
197
|
private createFallbackBee;
|
|
194
198
|
private initializeDockedHome;
|
|
195
199
|
private startRenderLoop;
|
|
@@ -275,4 +279,4 @@ declare class ThreeBeeRenderer implements BeeRenderer {
|
|
|
275
279
|
|
|
276
280
|
declare function applyLegacyBeeMaterialCompat(gltf: GLTF): Promise<void>;
|
|
277
281
|
|
|
278
|
-
export { type BeeActionChoice, type BeeActionHandler, type BeeAssetVariant, type BeeDockClickBehavior, type BeeDockPosition, type BeeDockVariant, type BeeMotionMode, type BeeQualityTier, type BeeRenderer, type BeeVisualState, type DockMotionOptions, type MoveToOptions, type PromptOptions, type SetCustomDockPositionOptions, type SpeakOptions, ThreeBeeRenderer, type ThreeBeeRendererOptions, type TooltipArrowEdge, applyLegacyBeeMaterialCompat };
|
|
282
|
+
export { type BeeActionChoice, type BeeActionHandler, type BeeAssetVariant, type BeeAvatarPreset, type BeeDockClickBehavior, type BeeDockPosition, type BeeDockVariant, type BeeMotionMode, type BeeQualityTier, type BeeRenderer, type BeeVisualState, type DockMotionOptions, type MoveToOptions, type PromptOptions, type SetCustomDockPositionOptions, type SpeakOptions, ThreeBeeRenderer, type ThreeBeeRendererOptions, type TooltipArrowEdge, applyLegacyBeeMaterialCompat };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
|
|
3
3
|
|
|
4
4
|
type BeeVisualState = "idle" | "guiding" | "thinking" | "celebrating";
|
|
5
5
|
type BeeAssetVariant = "hero" | "runtime";
|
|
6
|
+
type BeeAvatarPreset = "bee" | "orb" | "ring";
|
|
6
7
|
type BeeQualityTier = "auto" | "high" | "balanced" | "low";
|
|
7
8
|
type BeeMotionMode = "auto" | "full" | "reduced";
|
|
8
9
|
|
|
@@ -35,6 +36,7 @@ interface DockMotionOptions {
|
|
|
35
36
|
}
|
|
36
37
|
interface ThreeBeeRendererOptions {
|
|
37
38
|
assetUrl?: string;
|
|
39
|
+
avatarPreset?: BeeAvatarPreset;
|
|
38
40
|
assetVariant?: BeeAssetVariant;
|
|
39
41
|
qualityTier?: BeeQualityTier;
|
|
40
42
|
enableShadows?: boolean;
|
|
@@ -190,6 +192,8 @@ declare class ThreeBeeRenderer implements BeeRenderer {
|
|
|
190
192
|
private createRenderer;
|
|
191
193
|
private createLights;
|
|
192
194
|
private loadBeeModel;
|
|
195
|
+
private createPresetAvatar;
|
|
196
|
+
private clearVisualRig;
|
|
193
197
|
private createFallbackBee;
|
|
194
198
|
private initializeDockedHome;
|
|
195
199
|
private startRenderLoop;
|
|
@@ -275,4 +279,4 @@ declare class ThreeBeeRenderer implements BeeRenderer {
|
|
|
275
279
|
|
|
276
280
|
declare function applyLegacyBeeMaterialCompat(gltf: GLTF): Promise<void>;
|
|
277
281
|
|
|
278
|
-
export { type BeeActionChoice, type BeeActionHandler, type BeeAssetVariant, type BeeDockClickBehavior, type BeeDockPosition, type BeeDockVariant, type BeeMotionMode, type BeeQualityTier, type BeeRenderer, type BeeVisualState, type DockMotionOptions, type MoveToOptions, type PromptOptions, type SetCustomDockPositionOptions, type SpeakOptions, ThreeBeeRenderer, type ThreeBeeRendererOptions, type TooltipArrowEdge, applyLegacyBeeMaterialCompat };
|
|
282
|
+
export { type BeeActionChoice, type BeeActionHandler, type BeeAssetVariant, type BeeAvatarPreset, type BeeDockClickBehavior, type BeeDockPosition, type BeeDockVariant, type BeeMotionMode, type BeeQualityTier, type BeeRenderer, type BeeVisualState, type DockMotionOptions, type MoveToOptions, type PromptOptions, type SetCustomDockPositionOptions, type SpeakOptions, ThreeBeeRenderer, type ThreeBeeRendererOptions, type TooltipArrowEdge, applyLegacyBeeMaterialCompat };
|
package/dist/index.js
CHANGED
|
@@ -959,6 +959,11 @@ var ThreeBeeRenderer = class {
|
|
|
959
959
|
this.scene.add(ambient, hemisphere, key, fill, rim);
|
|
960
960
|
}
|
|
961
961
|
async loadBeeModel() {
|
|
962
|
+
const preset = this.options.avatarPreset ?? "bee";
|
|
963
|
+
if (preset === "orb" || preset === "ring") {
|
|
964
|
+
this.createPresetAvatar(preset);
|
|
965
|
+
return true;
|
|
966
|
+
}
|
|
962
967
|
try {
|
|
963
968
|
const loader = new import_GLTFLoader.GLTFLoader();
|
|
964
969
|
registerPbrSpecularGlossinessGLTFPlugin(loader);
|
|
@@ -1019,9 +1024,69 @@ var ThreeBeeRenderer = class {
|
|
|
1019
1024
|
this.updateBeeScreenPosition();
|
|
1020
1025
|
return true;
|
|
1021
1026
|
} catch {
|
|
1027
|
+
if (this.options.assetUrl) {
|
|
1028
|
+
this.createPresetAvatar("orb");
|
|
1029
|
+
return true;
|
|
1030
|
+
}
|
|
1022
1031
|
return false;
|
|
1023
1032
|
}
|
|
1024
1033
|
}
|
|
1034
|
+
createPresetAvatar(preset) {
|
|
1035
|
+
this.runtimeWings = null;
|
|
1036
|
+
this.clearVisualRig();
|
|
1037
|
+
if (preset === "orb") {
|
|
1038
|
+
const orbMaterial = new THREE2.MeshPhysicalMaterial({
|
|
1039
|
+
color: 13228274,
|
|
1040
|
+
roughness: 0.28,
|
|
1041
|
+
metalness: 0.04,
|
|
1042
|
+
clearcoat: 0.45,
|
|
1043
|
+
emissive: 9087192,
|
|
1044
|
+
emissiveIntensity: 0.18
|
|
1045
|
+
});
|
|
1046
|
+
const orb = new THREE2.Mesh(new THREE2.SphereGeometry(14, 32, 32), orbMaterial);
|
|
1047
|
+
this.visualRig.add(orb);
|
|
1048
|
+
} else {
|
|
1049
|
+
const ringMaterial = new THREE2.MeshPhysicalMaterial({
|
|
1050
|
+
color: 13943976,
|
|
1051
|
+
transparent: true,
|
|
1052
|
+
opacity: 0.72,
|
|
1053
|
+
roughness: 0.12,
|
|
1054
|
+
metalness: 0.02,
|
|
1055
|
+
side: THREE2.DoubleSide
|
|
1056
|
+
});
|
|
1057
|
+
const ring = new THREE2.Mesh(new THREE2.TorusGeometry(16, 2.4, 16, 64), ringMaterial);
|
|
1058
|
+
ring.rotation.x = Math.PI / 2.3;
|
|
1059
|
+
const core = new THREE2.Mesh(
|
|
1060
|
+
new THREE2.SphereGeometry(6, 24, 24),
|
|
1061
|
+
new THREE2.MeshPhysicalMaterial({
|
|
1062
|
+
color: 15787730,
|
|
1063
|
+
roughness: 0.34,
|
|
1064
|
+
metalness: 0.05
|
|
1065
|
+
})
|
|
1066
|
+
);
|
|
1067
|
+
this.visualRig.add(ring, core);
|
|
1068
|
+
}
|
|
1069
|
+
this.applyHomeFacing(true);
|
|
1070
|
+
this.updateBeeScreenPosition();
|
|
1071
|
+
}
|
|
1072
|
+
clearVisualRig() {
|
|
1073
|
+
while (this.visualRig.children.length > 0) {
|
|
1074
|
+
const child = this.visualRig.children[0];
|
|
1075
|
+
this.visualRig.remove(child);
|
|
1076
|
+
child.traverse((node) => {
|
|
1077
|
+
if (node instanceof THREE2.Mesh) {
|
|
1078
|
+
node.geometry?.dispose();
|
|
1079
|
+
const materials = Array.isArray(node.material) ? node.material : [node.material];
|
|
1080
|
+
for (const material of materials) {
|
|
1081
|
+
material.dispose();
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
this.mixer = null;
|
|
1087
|
+
this.actions.clear();
|
|
1088
|
+
this.activeActionName = null;
|
|
1089
|
+
}
|
|
1025
1090
|
createFallbackBee() {
|
|
1026
1091
|
this.runtimeWings = null;
|
|
1027
1092
|
const bodyMaterial = new THREE2.MeshStandardMaterial({ color: 13867825 });
|
package/dist/index.mjs
CHANGED
|
@@ -922,6 +922,11 @@ var ThreeBeeRenderer = class {
|
|
|
922
922
|
this.scene.add(ambient, hemisphere, key, fill, rim);
|
|
923
923
|
}
|
|
924
924
|
async loadBeeModel() {
|
|
925
|
+
const preset = this.options.avatarPreset ?? "bee";
|
|
926
|
+
if (preset === "orb" || preset === "ring") {
|
|
927
|
+
this.createPresetAvatar(preset);
|
|
928
|
+
return true;
|
|
929
|
+
}
|
|
925
930
|
try {
|
|
926
931
|
const loader = new GLTFLoader();
|
|
927
932
|
registerPbrSpecularGlossinessGLTFPlugin(loader);
|
|
@@ -982,9 +987,69 @@ var ThreeBeeRenderer = class {
|
|
|
982
987
|
this.updateBeeScreenPosition();
|
|
983
988
|
return true;
|
|
984
989
|
} catch {
|
|
990
|
+
if (this.options.assetUrl) {
|
|
991
|
+
this.createPresetAvatar("orb");
|
|
992
|
+
return true;
|
|
993
|
+
}
|
|
985
994
|
return false;
|
|
986
995
|
}
|
|
987
996
|
}
|
|
997
|
+
createPresetAvatar(preset) {
|
|
998
|
+
this.runtimeWings = null;
|
|
999
|
+
this.clearVisualRig();
|
|
1000
|
+
if (preset === "orb") {
|
|
1001
|
+
const orbMaterial = new THREE2.MeshPhysicalMaterial({
|
|
1002
|
+
color: 13228274,
|
|
1003
|
+
roughness: 0.28,
|
|
1004
|
+
metalness: 0.04,
|
|
1005
|
+
clearcoat: 0.45,
|
|
1006
|
+
emissive: 9087192,
|
|
1007
|
+
emissiveIntensity: 0.18
|
|
1008
|
+
});
|
|
1009
|
+
const orb = new THREE2.Mesh(new THREE2.SphereGeometry(14, 32, 32), orbMaterial);
|
|
1010
|
+
this.visualRig.add(orb);
|
|
1011
|
+
} else {
|
|
1012
|
+
const ringMaterial = new THREE2.MeshPhysicalMaterial({
|
|
1013
|
+
color: 13943976,
|
|
1014
|
+
transparent: true,
|
|
1015
|
+
opacity: 0.72,
|
|
1016
|
+
roughness: 0.12,
|
|
1017
|
+
metalness: 0.02,
|
|
1018
|
+
side: THREE2.DoubleSide
|
|
1019
|
+
});
|
|
1020
|
+
const ring = new THREE2.Mesh(new THREE2.TorusGeometry(16, 2.4, 16, 64), ringMaterial);
|
|
1021
|
+
ring.rotation.x = Math.PI / 2.3;
|
|
1022
|
+
const core = new THREE2.Mesh(
|
|
1023
|
+
new THREE2.SphereGeometry(6, 24, 24),
|
|
1024
|
+
new THREE2.MeshPhysicalMaterial({
|
|
1025
|
+
color: 15787730,
|
|
1026
|
+
roughness: 0.34,
|
|
1027
|
+
metalness: 0.05
|
|
1028
|
+
})
|
|
1029
|
+
);
|
|
1030
|
+
this.visualRig.add(ring, core);
|
|
1031
|
+
}
|
|
1032
|
+
this.applyHomeFacing(true);
|
|
1033
|
+
this.updateBeeScreenPosition();
|
|
1034
|
+
}
|
|
1035
|
+
clearVisualRig() {
|
|
1036
|
+
while (this.visualRig.children.length > 0) {
|
|
1037
|
+
const child = this.visualRig.children[0];
|
|
1038
|
+
this.visualRig.remove(child);
|
|
1039
|
+
child.traverse((node) => {
|
|
1040
|
+
if (node instanceof THREE2.Mesh) {
|
|
1041
|
+
node.geometry?.dispose();
|
|
1042
|
+
const materials = Array.isArray(node.material) ? node.material : [node.material];
|
|
1043
|
+
for (const material of materials) {
|
|
1044
|
+
material.dispose();
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
this.mixer = null;
|
|
1050
|
+
this.actions.clear();
|
|
1051
|
+
this.activeActionName = null;
|
|
1052
|
+
}
|
|
988
1053
|
createFallbackBee() {
|
|
989
1054
|
this.runtimeWings = null;
|
|
990
1055
|
const bodyMaterial = new THREE2.MeshStandardMaterial({ color: 13867825 });
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kibee/renderer-three",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
|
-
"sideEffects": [
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"*.css"
|
|
9
|
+
],
|
|
8
10
|
"exports": {
|
|
9
11
|
".": {
|
|
10
12
|
"types": "./dist/index.d.ts",
|
|
@@ -13,7 +15,9 @@
|
|
|
13
15
|
},
|
|
14
16
|
"./styles.css": "./dist/styles.css"
|
|
15
17
|
},
|
|
16
|
-
"files": [
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
17
21
|
"scripts": {
|
|
18
22
|
"build": "tsup src/index.ts --format cjs,esm --dts --clean --tsconfig tsconfig.build.json && cp src/styles.css dist/styles.css",
|
|
19
23
|
"dev": "tsup src/index.ts --format cjs,esm --dts --watch"
|
|
@@ -27,5 +31,8 @@
|
|
|
27
31
|
},
|
|
28
32
|
"devDependencies": {
|
|
29
33
|
"tsup": "^8.5.1"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
30
37
|
}
|
|
31
38
|
}
|