我正在尝试在每个面上创建一个具有不同纹理的three.js立方体.
基本上是一个骰子.这是在我的沙盒环境中,所以应该只在每侧产生一个带有骰子图像(1-6)的旋转立方体.完成后,我打算将其用于浏览器基础游戏.这个例子我只在Chrome中测试过,虽然考虑将其更改为画布渲染器以获得额外的浏览器支持.
在这里看了几个关于SO和其他大量谷歌搜索的问题,尽管我得到了答案(实际上看起来相当简单),但我根本无法让它发挥作用.
我是three.js的新手,但不是JavaScript.
我用来参考的页面是
和enriquemorenotent.com - three.js在每个面上构建一个具有不同材质的立方体
我的守则
var camera, scene, renderer, dice;
init();
animate();
function init() {
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 1, 1000);
camera.position.set(110, 110, 250);
camera.lookAt(scene.position);
scene.add(camera);
var materials = [
new THREE.MeshLambertMaterial({
map: THREE.ImageUtils.loadTexture('/Content/Images/dice-1-hi.png')
}),
new THREE.MeshLambertMaterial({
map: THREE.ImageUtils.loadTexture('/Content/Images/dice-2-hi.png')
}),
new THREE.MeshLambertMaterial({
map: THREE.ImageUtils.loadTexture('/Content/Images/dice-3-hi.png')
}),
new THREE.MeshLambertMaterial({
map: THREE.ImageUtils.loadTexture('/Content/Images/dice-4-hi.png')
}),
new THREE.MeshLambertMaterial({ …Run Code Online (Sandbox Code Playgroud) 这是一个与如何为中型到大型应用程序构建ASP.NET MVC项目相关的问题.
我以为我理解了MVC的概念,但在研究了中型和大型应用程序的架构后,我很困惑.(试图考虑可扩展性,可扩展性和持续维护)
当我试图按照"最佳实践"的指导方针(来自包括印刷和网络的众多来源)来思考如何构建应用程序时,我的困惑就出现了
试图尊重像
现在在创建小型(基本的,简单的)MVC应用程序时,所有这些都在同一个项目中完成(在这种情况下我说的是Visual Studio Project),MVC"Layers"之间的分离非常多只是VS项目中的文件夹(完全独立的命名空间).
对于我们的一些其他项目,我们采用了服务 - >存储库样式,因此这一点不会有任何不同.
我们使用Entity Framework作为数据库持久性(DB第一种方法).
我们将数据库访问(EF内容)分离到另一个VS项目中,因此我们在解决方案中有一个Web项目和模型(或数据)项目.
Web项目具有控制器和视图,数据项目具有服务,存储库和EF内容.
我的困惑在于模型(或者可能理解域模型与视图模型)
如果我试图遵循这种方法(我认为),我会有一个域模型(EF和存储库层处理的模型),然后我会有一个视图模型?(Controller和视图将处理的模型),现在这些不是90%相同吗?这种方式是否只是让你两次编写模型代码?我确定我读过控制器和视图不应该有域模型的地方?
我们接近它的一种方法是EF使其所有模型类都是部分的.然后我们扩展同一个类并向其添加一个MetaDataType类来创建"视图模型"(将DataAnnotations添加到属性中)然后本质上相同的模型将通过所有层传递,但这是"最佳"实践(那里在我看来是一个分裂,这是不对的)
例如
[MetadataType(typeof(Product_Metadata))]
public partial class Product
{
//Pretty much deliberately kept empty, just so
// the EF model class can have the attribute added
//The other side of this partial class is of course in the EF models
}
public class Product_Metadata
{
[Required]
[Display(Name = "Product name")]
public string Name { get; set; }
[Required]
[Display(Name …Run Code Online (Sandbox Code Playgroud) 尝试使用 vuejs 3 和可组合 API 创建一个基于 Bootstrap 5 的(半)可重用模态组件。设法让它部分工作,
给定(主要是标准 Bootstrap 5 模式,但基于“show”属性添加类,以及正文和页脚中的插槽):
<script setup lang="ts">
defineProps({
show: {
type: Boolean,
default: false,
},
title: {
type: String,
default: "<<Title goes here>>",
},
});
</script>
<template>
<div class="modal fade" :class="{ show: show, 'd-block': show }"
id="exampleModal" tabindex="-1" aria-labelledby="" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{{ title }}</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<slot name="body" />
</div>
<div class="modal-footer">
<slot name="footer" />
<button type="button" class="btn …Run Code Online (Sandbox Code Playgroud) 得到一个负数(-2147483392)
我不明白为什么它(正确)投射到旗帜enum.
特定
[Flags]
public enum ReasonEnum
{
REASON1 = 1 << 0,
REASON2 = 1 << 1,
REASON3 = 1 << 2,
//etc more flags
//But the ones that matter for this are
REASON9 = 1 << 8,
REASON17 = 1 << 31
}
Run Code Online (Sandbox Code Playgroud)
为什么以下正确报告REASON9并REASON17基于负数?
var reason = -2147483392;
ReasonEnum strReason = (ReasonEnum)reason;
Console.WriteLine(strReason);
Run Code Online (Sandbox Code Playgroud)
.NET小提琴在这里
我说的正确,因为这是从一个COM组件被解雇事件的原因属性,当投为enum值,这是正确的在它转换到(按该事件)的值.标志枚举是根据COM对象的SDK文档.COM对象是第三方,我无法控制数字,基于接口,它将始终作为INT提供
c# ×2
architecture ×1
asp.net ×1
bootstrap-5 ×1
javascript ×1
three.js ×1
typescript ×1
vuejs3 ×1