javascript案例_如何在JavaScript中使用增强现实-一个案例研究
javascript案例
by Apurav Chauhan
通过Apurav Chauhan
如何在JavaScript中使用增强现实-一个案例研究 (How to use Augmented Reality with JavaScript — a case study)
In this experiment, I talk about how Augmented Reality with JS can be used to make learning more fun and interactive. The case study will discuss the design process, implementation and feedback from children in the age group 2 to 10 years.
在这个实验中,我谈论了如何使用JS增强现实技术来使学习变得更加有趣和互动。 该案例研究将讨论2至10岁年龄段儿童的设计过程,实施和反馈。
Augmented Reality (AR) has always attracted me, and in this experiment, I try to create a practical AR application. The use-case we will cover is primary education and we will see how we can make the learning fun and interactive. We will make an app to learn alphabets in three languages primarily: Punjabi, Hindi, and English.
增强现实(AR)一直吸引着我,在这个实验中,我尝试创建一个实用的AR应用程序。 我们将介绍的用例是小学教育,我们将看到如何使学习变得有趣和互动。 我们将制作一个应用程序来学习三种主要语言的字母:旁遮普语,北印度语和英语。
The Javascript Augmented Reality app currently doesn’t have plane detection. For simplicity’s sake we are only superimposing our objects over the viewport with 3d motion tracking.
Javascript增强现实应用程序当前没有平面检测。 为简单起见,我们仅使用3d运动跟踪将对象叠加在视口上。
结束目标 (END GOAL)
Below is a demo of our Javascript AR experiment. You can download and play with the app here.
以下是我们的Javascript AR实验的演示。 您可以在此处下载并使用该应用程序。
The full code has been open-sourced for learning purposes and is available here.
完整的代码已开源,用于学习目的,可在此处获得 。
设计过程 (The Design Process)
To make the learning fun and effortless, I am relying on the following points:
为了使学习变得有趣而轻松,我依靠以下几点:
- Active participation of the child儿童的积极参与
- Child’s physical activity instead of sitting in one place孩子的体育活动,而不是坐在一个地方
- A bit of effort in finding the alphabets.查找字母需要一些努力。
- Intuitive UX/UI.直观的UX / UI。
The core theme of the app will be quite similar to the famous Pokemon Go Augmented reality app. Only two main components will be involved: the Camera Viewport and Alphabets.
该应用程序的核心主题将与著名的Pokemon Go Augmented现实应用程序非常相似。 仅涉及两个主要组成部分:“ 摄影机视口”和“ 字母” 。
AR游戏的Alphabet UX (Alphabet UX for AR Game)
Iteration 1
迭代1
In our first iteration we have 2d alphabets which we will try to merge in our camera viewport. The idea of the Augmented Reality(AR) app is to have children find these alphabet letters in a room or space around them. The prototype after merging the space with 2d alphabets will look something like this:
在我们的第一个迭代中,我们有2d字母,我们将尝试将其合并到相机视口中。 增强现实(AR)应用程序的想法是让孩子们在他们周围的房间或空间中找到这些字母。 将空间与2d字母合并后,原型将如下所示:
As you can see above, the immersive experience is missing with a 2d model because the human eye sees things in 3d.
正如您在上面看到的那样,由于人眼只能看到3D物体,因此2D模型缺少沉浸式体验。
Iteration 2
迭代2
Lets try to create a 3d model and see if we can improve the experience of our Javascript-based Augmented Reality game:
让我们尝试创建3D模型,看看是否可以改善基于Javascript的增强现实游戏的体验:
And below is the comparison of the experience of a motion sensor with 2d vs 3d alphabet models. As you can see, 3D naturally gives you a much more immersive experience when it comes to Augmented reality.
下面是2d与3d字母模型的运动传感器体验的比较。 如您所见,在增强现实方面,3D自然为您提供了更加身临其境的体验。
AR实施流程 (The AR Implementation process)
To implement the above AR concept, I’ll be using the following tools and technologies:
为了实现上述AR概念,我将使用以下工具和技术:
Ionic Framework: For building the hybrid app
Ionic框架 :用于构建混合应用程序
Aframe: For bringing the Virtual reality (VR) and Augmented Reality (AR) experience to our app
Aframe :将虚拟现实(VR)和增强现实(AR)体验引入我们的应用程序
MagicaVoxel: For creating our 3D models
MagicaVoxel :用于创建我们的3D模型
The basic app building process is very simple. You can follow my earlier post to learn how to go about building and deploying an app using the Ionic framework here.
基本的应用程序构建过程非常简单。 您可以按照我之前的文章在此处学习如何使用Ionic框架构建和部署应用程序。
Once you have followed the above tutorial to create a simple app, it’s time to integrate Aframe to bring our 3D alphabets with motion sensors into our app.
一旦您按照上述教程创建了一个简单的应用程序,就可以将Aframe集成到我们的应用程序中,将带运动传感器的3D字母集成到应用程序中。
Just load the below Aframe core and Aframe loader libraries in ionic’s project index.html file:
只需在ionic的项目index.html文件中加载以下Aframe核心和Aframe加载器库:
<script src="https://aframe.io/releases/0.8.2/aframe.min.js"></script>
<script src="https://rawgit.com/donmccurdy/aframe-extras/v2.1.1/dist/aframe-extras.loaders.min.js"></script>
With this we are ready to do some AR/VR magic in our Javascript code base.
这样,我们就可以在我们的Javascript代码库中做一些AR / VR魔术了。
Now in your home component’s home.html, let’s include our 3D models exported from magicavoxel:
现在,在您的home组件的home.html中,包括从magicavoxel导出的3D模型:
And this should make a 3D scene ready for interaction with all motion sensors ready:
这应该使3D场景准备好与所有运动传感器进行交互:
添加增强现实效果 (Adding Augmented Reality Effect)
The final part of this experiment is to add the Augmented Reality (AR) feeling in our Javascript-based hybrid app. As already explained, Augmented Reality is when you superimpose 3D models or other objects on top of your camera viewport. So the only thing missing is the camera viewport behind our scene.
该实验的最后一部分是在基于Javascript的混合应用程序中添加增强现实(AR)感觉。 如前所述,增强现实是指将3D模型或其他对象叠加在摄影机视口上方时。 因此,唯一缺少的是我们背后的摄影机视口。
To do this, we use the camera preview plugin as explained here. And here is the full gist after integration with the camera preview plugin:
要做到这一点,我们使用相机的预览插件作为解释在这里 。 这是与相机预览插件集成后的完整要点:
We also need to ensure that our backgrounds are transparent so that the camera preview is visible in mobile. This is very IMPORTANT otherwise you might feel that the plugin is not working. Here is the home.scss file with transparency css enabled:
我们还需要确保背景是透明的,以便在移动设备中可以看到相机预览。 这非常重要,否则您可能会觉得插件无法正常工作。 这是启用了透明css的home.scss文件:
And this is what it would finally look like:
这就是最终的样子:
用户对我们的增强现实JS游戏的React (User reaction to our Augmented reality JS game)
The final step to measure the success of your concept is real user validation — in our case, kids :) And below is their live feedback recorded.
衡量您的概念是否成功的最后一步是真实的用户验证-在我们的情况下,孩子们:)下面是他们的实时反馈记录。
It was pretty clear that each one of them enjoyed the game and we got full points on fun part. However, initially I had to tell them to move the phone in space to find the letters. Points lost in terms of intuitiveness :(
很明显,他们每个人都很喜欢这款游戏,而我们在有趣的部分上获得了满分。 但是,起初我必须告诉他们将手机移到太空中才能找到字母。 凭直觉而失去的点数:(
用户对增强现实JS游戏的反馈 (User feedback for Augmented Reality JS game)
最后的想法 (Final Thoughts)
Well it was an exciting project and I could see a lot of potential for Augmented Reality in learning and education. Children really like it and it surely adds the missing fun factor to education, especially in our monotonous Education system.
好吧,这是一个令人兴奋的项目,我可以在学习和教育中看到增强现实的巨大潜力。 孩子们真的很喜欢它,它肯定会增加教育中缺少的乐趣因素,尤其是在我们单调的教育系统中。
Feel free to comment and share your feedback.
随时发表评论并分享您的反馈。
资料下载 (Downloads)
The code for this app is available in github. Feel free to play and push new features in it. I’ll be happy to push updates over production.
该应用程序的代码可在github中找到 。 随意播放并推送其中的新功能。 我很乐意将更新推送到生产之上。
You can download the app for android here.
您可以在此处下载适用于Android的应用程序。
翻译自: https://www.freecodecamp.org/news/augmented-reality-with-javascript-a-case-study-c9cffaadcf07/
javascript案例
相关文章:

久未更 ~ 一之 —— 关于ToolBar
很久没更博客了,索性开一个久未更 系列 > > > > > 久未更 系列一:关于ToolBar的使用(后续补充) 1 //让 ToolBar 单独使用深色主题 使得 toolbar 中元素 变为淡色 2 android:theme"style/ThemeOverlay.AppCompat.Dark.ActionBar"…
SQLServer怎样把本地数据导入到远程服务器上(转载)
平常用到mssql时间比较少,总是过一段时间就忘记应该怎么操作了。当要做mssq把本地数据导入到远程服务器的时候,就去网上搜索很久都没有图解的,所以今天自己收集一下免得下次又到处去找。希望对自己,同时对其它需要的人都有一定的帮…

input 默认样式的修改
/* 修改input选中的默认边框样式 */ outline: none; /* 修改input的选中时的光标颜色 */ caret-color:red; /* 修改input的选中时的默认边框 */ border: none; /* 修改input的提示文字的默认样式 */ input::-webkit-input-placeholder{color:#d0d0d0;}

巨石加密_点餐:如何吃一个可怕的巨石
巨石加密by Alan Ridlehoover通过艾伦里德尔霍弗 点餐:如何吃一个可怕的巨石 (Ordering Take Out: How to Eat a Scary Monolith) Martin Fowler said:马丁福勒(Martin Fowler) 说 : Almost all the successful microservice stories have started wit…

Halcon学习之六:获取Image图像中Region区域的特征参数
area_center_gray ( Regions, Image : : : Area, Row, Column ) 计算Image图像中Region区域的面积Area和重心(Row,Column)。 cooc_feature_image ( Regions, Image : : LdGray, Direction : Energy,Correlation, Homogeneity, Contrast ) …

dos下命令行执行程序时候注意程序所使用文件的路径问题
dos下命令行执行程序时候,最好是用cd命令先切换到程序所在目录下,这样就不会出现文件找不到的问题,如果由于特殊原因,不使用cd命令,而只使用路径命令时候程序中访问的资源也只能是改成绝对路径了,这样对有源…

Vant 使用之Toast Vant安装和使用
Vant 是一个VUE 的移动端组件库,里面有很多好用的组件。 第一步,安装和配置 Vant npm i vant -S npm i babel-plugin-import -D 安装完成之后,在项目 .babelrc 文件修改配置 plugins "plugins": [["import", {"…

15-5重构_重构-糟糕,我一直在向后做。
15-5重构by Justin Fuller贾斯汀富勒(Justin Fuller) 重构-糟糕,我一直在向后做。 (Refactoring — oops, I’ve been doing it backwards.) Welcome to my intervention. I’m a refactoring addict and I’m not afraid to admit it, but there’s only one prob…

JPush 使用教程
JPush 使用教程 自己使用的一些经验,为了方便直接从这里复制过去就行。 就当做个笔记,防止长时间忘记之后,还需要去官网看文档。 主要思路: sdk文件 三方依赖系统库 头文件 添加代理 初始化代码 1.版本信息 JPush : 2.2.0 Xco…

浏览器常见兼容性问题汇总
1、随便写几个标签,不加样式控制的情况下,各自的margin 和padding差异较大,解决方案是:*{margin:0;padding:0;} 2、块属性标签float后,又有横行的margin情况下,在IE6显示margin比设置的大,常出现…

VUE 动态绑定class
第一种:通过一个布尔值判断样式类是否生效 //isActive 是在data里面布尔值, rotateRight 是 class 样式类 //isActive 为true时样式类 rotateRight 生效 <div :class"{rotateRight:isActive}">abs</div> 第二种:通…

低声教育_我内心低声说:“成为建设者”
低声教育by Rebecca Radding由丽贝卡拉丁(Rebecca Radding) 我内心低声说:“成为建设者” (Something within me whispered: “Be the builder”) 加沙代码学院前任主持人Yasmin Hillis(自称嬉皮士)是一个内心的嬉皮士,她谈到了弗吉尼亚伍尔夫如何激发她…

【Web API系列教程】1.2 — Web API 2中的Action Results
前言 本节的主题是ASP.NET Web API怎样将控制器动作的返回值转换成HTTP的响应消息。 Web API控制器动作能够返回下列的不论什么值: 1。 void 2。 HttpResponseMessage 3, IHttpActionResult 4, Some other type 取决于返回的以上哪一种。…

前端开发常用单词
methods 方法 mounted 创建完成 export 输出 default 默认的 install 安装 components 组件 template 模板 params 参数 route 路线;途径 package 包;盒子;袋 ; toutes 路由器 plugin 插件 local host 本地 require 需要;依赖; storage 储存 prototype 原型 …

原生ajax的post操作
xml.open(方法,路径,是否开启异步); console.log(e);来找出数据所在位置; 调用 ajax只能传二进制或字符串,需要先把json转一下,JSON.stringify(); 获取到数据时我们要通过JSON.parse()再转成JSO…

jquery后学什么_我在训练营两年后学到了什么
jquery后学什么by Kara Luton卡拉卢顿(Kara Luton) 我在训练营两年后学到了什么 (What I’ve Learned Two Years Post-Bootcamp) It’s been two entire years since I left behind my career of being a music publicist — one I worked towards all of college and miracul…

ExecutorService 的理解与使用
接口 Java.util.concurrent.ExecutorService 表述了异步执行的机制,并且可以让任务在后台执行。壹個 ExecutorService 实例因此特别像壹個线程池。事实上,在 java.util.concurrent 包中的 ExecutorService 的实现就是壹個线程池的实现。 ExecutorService…

前后端交互,网络请求
这边文章主要根据我自己的前端开发工作经验,东拼西凑出来的一点理解,希望能够对大家有点帮助,如果有误导或者错误的地方还请帮助指正,感谢!!! 前后端交互我理解主要分为三个主要的部分…

HDU 1877 另一个版本 A+B
另一个版本 AB Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 12894 Accepted Submission(s): 4901Problem Description输入两个不超过整型定义的非负10进制整数A和B(<231-1)。输出AB的m (1 < m <10…

gatsby_如何使用Gatsby.js来获取内容
gatsbyby Dimitri Ivashchuk由Dimitri Ivashchuk 如何使用Gatsby.js来获取内容 (How to source content with Gatsby.js) Gatsby.js is a powerful static site generator (with dynamic capabilities) which can be used to build super performant web-sites. It has a very…

使用 AFNetworking 进行 XML 和 JSON 数据请求
(1)XML 数据请求 使用 AFNetworking 中的 AFHTTPRequestOperation 和 AFXMLParserResponseSerializer,另外结合第三方框架 XMLDictionary 进行数据转换 使用 XMLDictionary 的好处:有效避免自行实现 NSXMLParserDelegate 委托代理…

批处理+定时任务实现定时休息提醒
前言:俗话说的好,懒是第一生产力,懒是提高生产效率的必要条件。而现今windows是大部分人的第一生产工具,批处理定时任务这对黄金搭档就是提升生产效率的第一工具。大家在生产过程中经常会遇到各种周期性的重复的工作,比…

后端返回的数据中换行符 html换行
标签代码 <span v-html"model3_txt"></span> vue js代码 var txt "恭喜你\n获得某某某奖品"; if(txt.indexOf(\n)!-1){var reg new RegExp("/r/n", "g");txttxt.replace(reg, "<br/>");console.log(t…

vim block vim_如何不再害怕Vim
vim block vim精选最流行的命令以及如何使用它们 (A curation of the most popular commands and how to use them) If you’ve ever used Vim, you know how difficult it can get to reach the same speed as in a “normal” GUI editor. But once you do, the payoff is ex…

android EditText 限定中文个数与英文个数的解决方式
EditText 限定中文8个英文16个的解决方法。 在EditText上控件提供的属性中有限定最大最小长度的方法。可是,对于输入时,限定中文8个英文16个时,怎么办?相当于一个中文的长度是两个英文的长度。原理就不说了。自己看一下android的源…

根据二叉树的前序遍历和中序遍历重建二叉树
题目描述 输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。1 /**2 * Definition for …

VUE 监听当前路由 侦听器 watch
侦听器: 你可以利用侦听器,响应数据的变化,例如路由,和页面中data的值,可以在他们变化的时候写相应的处理逻辑在侦听器中。 侦听器的使用很简单: watch 对象就是侦听器,只有当侦听的值改变了它…

如何使用Bootstrap4和ES6创建自定义确认框
by Prashant Yadav通过Prashant Yadav 如何使用Bootstrap4和ES6创建自定义确认框 (How to create a custom confirm box with Bootstrap4 and ES6) We put lots of sweat into achieving a good design, but imagine a scenario where we have to use something which is styl…

RequireJS学习笔记(转)
前言进入移动前端是很不错的选择,这块也是我希望的道路,但是不熟悉啊。。。现在项目用的是requirebackbone,整个框架被封装了一次,今天看了代码搞不清楚,觉得应该先从源头抓起,所以再看看require了。上午是…

火狐中的table
在火狐浏览器中,table的th、td会存在小数转载于:https://www.cnblogs.com/likwin/p/7270817.html