Skip to content

Commit bd60944

Browse files
committed
Show texture with PlaneModelNode
1 parent a95374a commit bd60944

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

Ab4d.SharpEngine.Samples.BlazorWebAssembly/Pages/QuickStart.razor

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@
135135
_targetPositionCamera = new TargetPositionCamera()
136136
{
137137
Heading = 30,
138-
Attitude = -40,
139-
Distance = 300,
138+
Attitude = -30,
139+
Distance = 400,
140140
TargetPosition = new Vector3(0, 0, 0),
141141
ShowCameraLight = ShowCameraLightType.Auto,
142142
};
@@ -159,18 +159,17 @@
159159

160160
scene.SetAmbientLight(0.2f);
161161

162-
163162
float hashModelSize = 100;
164163
float hashModelBarThickness = 16;
165164
float hashModelBarOffset = 20;
166165

167166
var hashSymbolMesh = MeshFactory.CreateHashSymbolMesh(centerPosition: new Vector3(0, hashModelBarThickness * 0.5f, 0),
168-
shapeYVector: new Vector3(0, 0, 1),
169-
extrudeVector: new Vector3(0, hashModelBarThickness, 0),
170-
size: hashModelSize,
171-
barThickness: hashModelBarThickness,
172-
barOffset: hashModelBarOffset,
173-
name: "HashSymbolMesh");
167+
shapeYVector: new Vector3(0, 0, 1),
168+
extrudeVector: new Vector3(0, hashModelBarThickness, 0),
169+
size: hashModelSize,
170+
barThickness: hashModelBarThickness,
171+
barOffset: hashModelBarOffset,
172+
name: "HashSymbolMesh");
174173

175174
_hashMaterial = new StandardMaterial(diffuseColor: Color3.FromByteRgb(255, 197, 0));
176175
//_hashMaterial = new StandardMaterial(diffuseColor: Colors.Silver);
@@ -198,7 +197,7 @@
198197
MajorLinesFrequency = 5,
199198

200199
IsClosed = true,
201-
};
200+
};
202201
scene.RootNode.Add(wireGridNode);
203202

204203

@@ -209,9 +208,44 @@
209208
scene.RootNode.Add(sphereModelNode1);
210209
}
211210

211+
212+
if (sharpEngineSceneView.IsInitialized)
213+
AddTexturePlane();
214+
else
215+
sharpEngineSceneView.SceneViewInitialized += (sender, args) => AddTexturePlane();
216+
217+
212218
ShowInfoMessage("Initial 3D scene shown");
213219
}
214220

221+
private void AddTexturePlane()
222+
{
223+
var gpuDevice = sharpEngineSceneView.Scene.GpuDevice;
224+
if (gpuDevice == null)
225+
return;
226+
227+
Ab4d.SharpEngine.Utilities.TextureLoader.CreateTexture("ab4d-logo-256.png", gpuDevice, gpuImage =>
228+
{
229+
var textureMaterial = new StandardMaterial(gpuImage)
230+
{
231+
HasTransparency = true,
232+
};
233+
234+
var planeModelNode = new PlaneModelNode(centerPosition: new Vector3(0, 30, -150),
235+
size: new Vector2(60, 60),
236+
normal: new Vector3(0, 0, 1),
237+
heightDirection: new Vector3(0, 1, 0),
238+
name: "TexturePlane")
239+
{
240+
IsHitTestVisible = false,
241+
Material = textureMaterial,
242+
BackMaterial = textureMaterial,
243+
};
244+
245+
sharpEngineSceneView.Scene.RootNode.Add(planeModelNode);
246+
});
247+
}
248+
215249
private void UpdateRenderTime()
216250
{
217251
var statistics = sharpEngineSceneView.SceneView.Statistics;

0 commit comments

Comments
 (0)