我希望在带有Three.js的WebGL页面中有一个反射立方体表面.它应该像手机显示器,它反射一些光,但它仍然必须是黑色的.
我想在立方体上使用6种不同的纹理,每边一个,但是找不到错误.这是我目前的代码:
var texturen = new Array();
function initTexture(sFilename,texturen)
{
var anz = texturen.length;
texturen[anz] = gl.createTexture();
texturen[anz].image = new Image();
texturen[anz].image.onload = function()
{
gl.bindTexture(gl.TEXTURE_2D, texturen[anz]);
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
gl.texImage2D
(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, texturen[anz].image);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.bindTexture(gl.TEXTURE_2D, null);
}
texturen[anz].image.src = sFilename;
}
var mvMatrix = mat4.create();
var mvMatrixStack = [];
var pMatrix = mat4.create();
function mvPushMatrix() {
var copy = mat4.create();
mat4.set(mvMatrix, copy);
mvMatrixStack.push(copy);
}
function mvPopMatrix() {
if (mvMatrixStack.length == 0) {
throw …
Run Code Online (Sandbox Code Playgroud) 我正在使用 vue.js 并使用 stencil.js 创建了一个 web 组件。我不想将 Web 组件发布到 npm,这就是为什么我只是将其包含在我的 vue 项目的 src/assets 目录中。
但是我收到错误
[Vue warn]: Unknown custom element: <my-component> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
found in --->
<App> at src/app.vue
<Root>
Run Code Online (Sandbox Code Playgroud)
它与我在资产目录中已有的另一个组件一起工作没有问题。
它也无助于使用
Vue.config.ignoredElements = ['my-component'];
Run Code Online (Sandbox Code Playgroud)
因为当我在本地运行该组件时,该组件仍然是空的。
感谢您的帮助!
我想编写类似于three.js中的漏洞的东西.它应该是,例如一个3x3x3立方体,其中有1x1x1个洞.是否有可能,我首先使用像cubegeometry这样的东西,然后再使用另一个"几何"来削减我想要删除的东西?删除几何?:d
谢谢 :)
我有面部索引(指向点)和点,并希望在循环中绘制三角形.Web控制台给我这个错误:
WebGL: drawElements: bound element array buffer is too small for given count and offset
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
for(var i=1;i<38000;i++){
var vtx = new Float32Array(
[points[faces[i][1]][1],points[faces[i][1]][2],points[faces[i][1]][3],
points[faces[i][2]][1],points[faces[i][2]][2],points[faces[i][2]][3],
points[faces[i][3]][1],points[faces[i][3]][2],points[faces[i][3]][3]
]
);
var idx = new Uint16Array([0, 1]);
initBuffers(vtx, idx);
gl.lineWidth(1.0);
gl.uniform4f(shaderProgram.colorUniform, 0, 0, 0, 1);
gl.drawElements(gl.LINES, 3, gl.UNSIGNED_SHORT, 0);
unbindBuffers();
}
}
Run Code Online (Sandbox Code Playgroud)
例程没有任何东西.我该如何解决这个问题?
我有一个600px
宽度的图像。
它必须位于宽度为的引导程序col-xs-6
或12
div 内,300px
并且如果屏幕宽度小于,则必须调整其大小300px
。
如何在CSS 中使用width
和max-width
?
我见过很多线程询问如何为 jquery 的 css 方法使用变量,例如
var black='#000000';
$(this).css({'color':black});
Run Code Online (Sandbox Code Playgroud)
但没有人像这样反过来使用变量
var bg='background-color';
$(this).css({bg:'#000000'});
Run Code Online (Sandbox Code Playgroud)
对我来说,它不是这样工作的,所以我问,有没有办法让类似的东西工作,以便在脚本中多次使用“背景颜色”时节省一些空间?
谢谢!
我想使用具有特定默认日期的日期选择器,但不知何故这不起作用:
<input class="cal-datepicker" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-autoclose="true" data-date-today-highlight="true" data-date-default-view-date="01/01/2015">
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它工作?
这是我的源代码.它仍然无法正常工作.我想在一个立方体的6面上放置6张不同的图片,这是动画的.请帮忙 :)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<title>WebGL</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script>
<script type="text/javascript" src="webgl-utils.js"></script>
<script id="shader-fs" type="x-shader/x-fragment">
precision mediump float;
varying vec2 vTextureCoord;
uniform sampler2D uSampler;
void main(void) {
gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
}
</script>
<script id="shader-vs" type="x-shader/x-vertex">
attribute vec3 aVertexPosition;
attribute vec2 aTextureCoord;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
varying vec2 vTextureCoord;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
vTextureCoord = aTextureCoord;
}
</script>
<script type="text/javascript">
var …
Run Code Online (Sandbox Code Playgroud)