Updated preview images to be a higher resolution and added glass and gemstone dice
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 69 KiB |
62
src/dice/gemstone/GemstoneDice.js
Normal file
@ -0,0 +1,62 @@
|
||||
import * as BABYLON from "babylonjs";
|
||||
|
||||
import Dice from "../Dice";
|
||||
|
||||
import albedo from "./albedo.jpg";
|
||||
import metalRoughness from "./metalRoughness.jpg";
|
||||
import normal from "./normal.jpg";
|
||||
|
||||
class GemstoneDice extends Dice {
|
||||
static meshes;
|
||||
static material;
|
||||
|
||||
static getDicePhysicalProperties(diceType) {
|
||||
let properties = super.getDicePhysicalProperties(diceType);
|
||||
return { mass: properties.mass * 1.5, friction: properties.friction };
|
||||
}
|
||||
|
||||
static loadMaterial(materialName, textures, scene) {
|
||||
let pbr = new BABYLON.PBRMaterial(materialName, scene);
|
||||
pbr.albedoTexture = new BABYLON.Texture(textures.albedo);
|
||||
pbr.normalTexture = new BABYLON.Texture(textures.normal);
|
||||
pbr.metallicTexture = new BABYLON.Texture(textures.metalRoughness);
|
||||
pbr.useRoughnessFromMetallicTextureAlpha = false;
|
||||
pbr.useRoughnessFromMetallicTextureGreen = true;
|
||||
pbr.useMetallnessFromMetallicTextureBlue = true;
|
||||
|
||||
pbr.subSurface.isTranslucencyEnabled = true;
|
||||
pbr.subSurface.translucencyIntensity = 1.0;
|
||||
pbr.subSurface.minimumThickness = 5;
|
||||
pbr.subSurface.maximumThickness = 10;
|
||||
pbr.subSurface.tintColor = new BABYLON.Color3(190 / 255, 0, 220 / 255);
|
||||
|
||||
return pbr;
|
||||
}
|
||||
|
||||
static async load(scene) {
|
||||
if (!this.material) {
|
||||
this.material = this.loadMaterial(
|
||||
"gemstone_pbr",
|
||||
{ albedo, metalRoughness, normal },
|
||||
scene
|
||||
);
|
||||
}
|
||||
if (!this.meshes) {
|
||||
this.meshes = await this.loadMeshes(this.material, scene);
|
||||
}
|
||||
}
|
||||
|
||||
static async createInstance(diceType, scene) {
|
||||
if (!this.material || !this.meshes) {
|
||||
throw Error("Dice not loaded, call load before creating an instance");
|
||||
}
|
||||
|
||||
return Dice.createInstance(
|
||||
this.meshes[diceType],
|
||||
this.getDicePhysicalProperties(diceType),
|
||||
scene
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default GemstoneDice;
|
BIN
src/dice/gemstone/albedo.jpg
Executable file
After Width: | Height: | Size: 2.1 MiB |
BIN
src/dice/gemstone/metalRoughness.jpg
Executable file
After Width: | Height: | Size: 2.0 MiB |
BIN
src/dice/gemstone/normal.jpg
Executable file
After Width: | Height: | Size: 285 KiB |
BIN
src/dice/gemstone/preview.png
Normal file
After Width: | Height: | Size: 71 KiB |
64
src/dice/glass/GlassDice.js
Normal file
@ -0,0 +1,64 @@
|
||||
import * as BABYLON from "babylonjs";
|
||||
|
||||
import Dice from "../Dice";
|
||||
|
||||
import albedo from "./albedo.jpg";
|
||||
import mask from "./mask.png";
|
||||
import normal from "./normal.jpg";
|
||||
|
||||
class GlassDice extends Dice {
|
||||
static meshes;
|
||||
static material;
|
||||
|
||||
static getDicePhysicalProperties(diceType) {
|
||||
let properties = super.getDicePhysicalProperties(diceType);
|
||||
return { mass: properties.mass * 1.5, friction: properties.friction };
|
||||
}
|
||||
|
||||
static loadMaterial(materialName, textures, scene) {
|
||||
let pbr = new BABYLON.PBRMaterial(materialName, scene);
|
||||
pbr.albedoTexture = new BABYLON.Texture(textures.albedo);
|
||||
pbr.normalTexture = new BABYLON.Texture(textures.normal);
|
||||
pbr.roughness = 0.25;
|
||||
pbr.metallic = 0;
|
||||
pbr.subSurface.isRefractionEnabled = true;
|
||||
pbr.subSurface.indexOfRefraction = 2.0;
|
||||
pbr.subSurface.refractionIntensity = 1.2;
|
||||
pbr.subSurface.isTranslucencyEnabled = true;
|
||||
pbr.subSurface.translucencyIntensity = 2.5;
|
||||
pbr.subSurface.minimumThickness = 10;
|
||||
pbr.subSurface.maximumThickness = 10;
|
||||
pbr.subSurface.tintColor = new BABYLON.Color3(43 / 255, 1, 115 / 255);
|
||||
pbr.subSurface.thicknessTexture = new BABYLON.Texture(textures.mask);
|
||||
pbr.subSurface.useMaskFromThicknessTexture = true;
|
||||
|
||||
return pbr;
|
||||
}
|
||||
|
||||
static async load(scene) {
|
||||
if (!this.material) {
|
||||
this.material = this.loadMaterial(
|
||||
"glass_pbr",
|
||||
{ albedo, mask, normal },
|
||||
scene
|
||||
);
|
||||
}
|
||||
if (!this.meshes) {
|
||||
this.meshes = await this.loadMeshes(this.material, scene);
|
||||
}
|
||||
}
|
||||
|
||||
static async createInstance(diceType, scene) {
|
||||
if (!this.material || !this.meshes) {
|
||||
throw Error("Dice not loaded, call load before creating an instance");
|
||||
}
|
||||
|
||||
return Dice.createInstance(
|
||||
this.meshes[diceType],
|
||||
this.getDicePhysicalProperties(diceType),
|
||||
scene
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default GlassDice;
|
BIN
src/dice/glass/albedo.jpg
Executable file
After Width: | Height: | Size: 583 KiB |
BIN
src/dice/glass/mask.png
Normal file
After Width: | Height: | Size: 217 KiB |
BIN
src/dice/glass/normal.jpg
Executable file
After Width: | Height: | Size: 283 KiB |
BIN
src/dice/glass/preview.png
Normal file
After Width: | Height: | Size: 44 KiB |
@ -6,6 +6,8 @@ import NebulaDice from "./nebula/NebulaDice";
|
||||
import SunriseDice from "./sunrise/SunriseDice";
|
||||
import SunsetDice from "./sunset/SunsetDice";
|
||||
import WalnutDice from "./walnut/WalnutDice";
|
||||
import GlassDice from "./glass/GlassDice";
|
||||
import GemstoneDice from "./gemstone/GemstoneDice";
|
||||
|
||||
import GalaxyPreview from "./galaxy/preview.png";
|
||||
import IronPreview from "./iron/preview.png";
|
||||
@ -13,6 +15,8 @@ import NebulaPreview from "./nebula/preview.png";
|
||||
import SunrisePreview from "./sunrise/preview.png";
|
||||
import SunsetPreview from "./sunset/preview.png";
|
||||
import WalnutPreview from "./walnut/preview.png";
|
||||
import GlassPreview from "./glass/preview.png";
|
||||
import GemstonePreview from "./gemstone/preview.png";
|
||||
|
||||
export const diceClasses = {
|
||||
galaxy: GalaxyDice,
|
||||
@ -21,6 +25,8 @@ export const diceClasses = {
|
||||
sunset: SunsetDice,
|
||||
iron: IronDice,
|
||||
walnut: WalnutDice,
|
||||
glass: GlassDice,
|
||||
gemstone: GemstoneDice,
|
||||
};
|
||||
|
||||
export const dicePreviews = {
|
||||
@ -30,6 +36,8 @@ export const dicePreviews = {
|
||||
sunset: SunsetPreview,
|
||||
iron: IronPreview,
|
||||
walnut: WalnutPreview,
|
||||
glass: GlassPreview,
|
||||
gemstone: GemstonePreview,
|
||||
};
|
||||
|
||||
export const dice = Object.keys(diceClasses).map((key) => ({
|
||||
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 69 KiB |